# jsonDecode

\
Decodes input string into a JSON object. Requires no parameters. Input must be a string.

This function allows users to convert data columns with string input proper JSON object. This function helps datasets with string formats to be converted to JSON objects for further processing.&#x20;

### Example 1:&#x20;

Step 1: Create an empty **jsondecode\_example\_1** using AIOps studio as shown in the below screenshot.

![Empty pipeline jsondecode\_example\_1 created via RDA](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHGyYRteW7Hb_xxdco%2F-MeHHQb4fkiE4HNfcpvP%2FScreen%20Shot%202021-07-10%20at%202.18.53%20PM.png?alt=media\&token=c5dfad68-7679-4a69-a53e-2f318a7f0ec3)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a simple records using AIOps studio.`*\
\
*`##### RDA function jsonDecode is used to demo this example.`*\
*`##### This function uses string input of multiple rows and converts into JSON`* \
*`##### Object`*\
\
*`@dm:empty`* \
*`--> @dm:addrow attributes = '{"a":1, "b":2, "c": { "d":3, "e":4} }'`*  \
*`--> @dm:addrow attributes = '{"p":11, "b":12, "c": { "d":13, "e":14} }'`* \
*`--> @dm:addrow attributes = '{"cfx":4301}'`*\
*`--> @dm:addrow attributes = '{"rda":999}'`*\
*`--> @dm:map from = 'attributes' & to = "json_attributes" & func = "jsonDecode"`* <br>

![Pipeline code added to the empty pipeline created  ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHLCgs1Uumki8BsWkN%2F-MeHLecpQGylEkEMHdyU%2FScreen%20Shot%202021-07-10%20at%202.37.13%20PM.png?alt=media\&token=d9a6107a-0337-4428-b79c-5c5d860702a8)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button for any errors as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHLvYij4fDDuSJMWCT%2F-MeHMBlaPzlAWjmQCjuv%2FScreen%20Shot%202021-07-10%20at%202.39.50%20PM.png?alt=media\&token=2de76387-ff74-4e7f-8eb3-7729f7866190)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Execution of pipeline without any errors as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHMKdnP6jnwrxjhdd_%2F-MeHMf0A_8vMi0M7tURW%2FScreen%20Shot%202021-07-10%20at%202.41.52%20PM.png?alt=media\&token=db58c045-be00-4a0f-b893-7054d380307c)

Step 5: RDA uses the dm function 'jsonDecode' to convert string attributes as shown above into JSON objects and saves under the column "json\_attributes' and prints the output for each dataset (or row) as shown in the following screenshot.

![String objects are converted to JSON objects and are stored under json\_attributes as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHNHA3wfjxsUp9rlys%2F-MeHNiz8uOGpl25iDwIc%2FScreen%20Shot%202021-07-10%20at%202.46.29%20PM.png?alt=media\&token=d83a46e2-9991-4f8f-9c16-46f9cf063131)

**Note: The above example uses string objects that contain numeric values.**&#x20;

### Example 2:&#x20;

Step 1: Create an empty **jsondecode\_example\_2** using AIOps studio as shown in the below screenshot.

![Empty pipeline jsondecode\_example\_2 created via RDA](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHOBkE8zI89e00RM_y%2F-MeHOXnW2sb0O2u4smDT%2FScreen%20Shot%202021-07-10%20at%202.49.59%20PM.png?alt=media\&token=601766f4-ec24-4646-af38-3f621d664e80)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a simple records using AIOps studio.`*\
\
*`##### RDA function jsonDecode is used to demo this example.`*\
*`##### This function uses string input of multiple rows and converts into JSON`* \
*`##### Object`*\
\
*`@dm:empty`* \
*`--> @dm:addrow attributes = '{"a":"r", "b":"d", "c":"a"}'`*\
*`--> @dm:addrow attributes = '{"cfx":"tool", "rda":"data", "use":"transformation"}'`*\
*`--> @dm:map from = 'attributes' & to = "json_attributes" & func = "jsonDecode"`* <br>

![Pipeline code added ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHPSAhpMms_-p38D2j%2F-MeHUPLbIuF_3_cnfHiB%2FScreen%20Shot%202021-07-10%20at%203.15.27%20PM.png?alt=media\&token=5a2a1aa2-901f-4150-ad93-59e145ba11bf)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button for any errors as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHUiNGWCExIVThDCLj%2F-MeHUyxw6bsx3zLUyEo8%2FScreen%20Shot%202021-07-10%20at%203.18.11%20PM.png?alt=media\&token=d4d591a4-b8be-4414-8dd4-4b0b91adb196)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Execution of pipeline without any errors as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHV6O0zb-DoeqF8sGg%2F-MeHVRZlNOi9CJf_A72y%2FScreen%20Shot%202021-07-10%20at%203.20.07%20PM.png?alt=media\&token=ff8fbb11-75bb-43d5-9b31-4e537175eebf)

Step 5: RDA uses the dm function 'jsonDecode' to convert string attributes as shown above into JSON objects and saves under the column "json\_attributes' and prints the output for each dataset (or row) as shown in the following screenshot.

![String objects are converted to JSON objects and are stored under json\_attributes as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeHVYjfuA7c4cEDuqck%2F-MeHVyJlDm9qYdYFyGWi%2FScreen%20Shot%202021-07-10%20at%203.22.27%20PM.png?alt=media\&token=48f5ebd8-da44-4e82-9aea-9dbabd90fc15)

**Note: The above example uses string objects that contain string values.**&#x20;

###
