jsonDecode
Last updated
Last updated
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.
Step 1: Create an empty jsondecode_example_1 using AIOps studio as shown in the below screenshot.
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.
##### 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"
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
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.
Note: The above example uses string objects that contain numeric values.
Step 1: Create an empty jsondecode_example_2 using AIOps studio as shown in the below screenshot.
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.
##### 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"
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
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.
Note: The above example uses string objects that contain string values.