JSON Object - Get values
Declaration
<AMJSON ACTIVITY="get_values" JSONOBJECT="text" PATH="text" RESULTVARIABLE="text" RESULTDATASET="text" />
Description
Extracts specific field values from within an existing Automate Desktop JSON Object, and then stores the values in a variable and/or creates and populates a dataset with the values.
Practical usage
JSON is primarily used to transmit data between a server and web application, as an alternative to XML. Use this activity to extract specific values from within an existing Automate Desktop JSON Object, and then stores the values in a variable and/or creates and populates a dataset with the values.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
JSON Object name | Text | Yes | (Empty) | JSONOBJECT="donuts" | The name of the object with which to store JSON decoded data. |
Field to get | Text | Yes | (Empty) |
|
The JSON field to extract values from. To select a field, click Select field, and then from the dialog that appears, choose the desired field by clicking its hyperlink. |
Populate variable with value | Text | Yes, if the Create and populate dataset parameter is empty | (Empty) | RESULTVARIABLE="varName" | The name of an existing variable to use to populate with the extracted values. |
Create and populate dataset | Text | No | (Empty) | RESULTDATASET="theDataset" | The name of the dataset to create and populate with the extracted JSON values. |
Example
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Description
This sample task extracts values from an Automate Desktop JSON Object, and then creates and populates a dataset with the values.
<AMVARIABLE NAME="results" VALUE="%%" />
<AMJSON JSONOBJECT="donuts" JSONSTRING="{
 "id": "0001",
 "type": "donut",
 "name": "Cake",
 "ppu": 0.55,
 "batters":
 {
 "batter":
 [
 { "id": "1001", "type": "Regular" },
 { "id": "1002", "type": "Chocolate" },
 { "id": "1003", "type": "Blueberry" },
 { "id": "1004", "type": "Devil's Food" }
 ]
 },
 "topping":
 [
 { "id": "5001", "type": "None" },
 { "id": "5002", "type": "Glazed" },
 { "id": "5005", "type": "Sugar" },
 { "id": "5007", "type": "Powdered Sugar" },
 { "id": "5006", "type": "Chocolate with Sprinkles" },
 { "id": "5003", "type": "Chocolate" },
 { "id": "5004", "type": "Maple" }
 ]
}" />
<AMJSON ACTIVITY="get_values" JSONOBJECT="donuts" PATH="batters.batter[1].type" RESULTDATASET="dataset" />