JSON Object - Get values

Declaration

<AMJSON ACTIVITY="get_values" JSONOBJECT="text" PATH="text" RESULTVARIABLE="text" RESULTDATASET="text" />

Related Topics    

Description

Extracts specific field values from within an existing Automate 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 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)
  • PATH=""
  • PATH="fillings"
  • PATH="fillings.filling[2]"
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.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task extracts values from an Automate JSON Object, and then creates and populates a dataset with the values.

Copy
<AMVARIABLE NAME="results" VALUE="%%" />
<AMJSON JSONOBJECT="donuts" JSONSTRING="{&#xD;&#xA;    &quot;id&quot;: &quot;0001&quot;,&#xD;&#xA;    &quot;type&quot;: &quot;donut&quot;,&#xD;&#xA;    &quot;name&quot;: &quot;Cake&quot;,&#xD;&#xA;    &quot;ppu&quot;: 0.55,&#xD;&#xA;    &quot;batters&quot;:&#xD;&#xA;        {&#xD;&#xA;            &quot;batter&quot;:&#xD;&#xA;                [&#xD;&#xA;                    { &quot;id&quot;: &quot;1001&quot;, &quot;type&quot;: &quot;Regular&quot; },&#xD;&#xA;                    { &quot;id&quot;: &quot;1002&quot;, &quot;type&quot;: &quot;Chocolate&quot; },&#xD;&#xA;                    { &quot;id&quot;: &quot;1003&quot;, &quot;type&quot;: &quot;Blueberry&quot; },&#xD;&#xA;                    { &quot;id&quot;: &quot;1004&quot;, &quot;type&quot;: &quot;Devil's Food&quot; }&#xD;&#xA;                ]&#xD;&#xA;        },&#xD;&#xA;    &quot;topping&quot;:&#xD;&#xA;        [&#xD;&#xA;            { &quot;id&quot;: &quot;5001&quot;, &quot;type&quot;: &quot;None&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5002&quot;, &quot;type&quot;: &quot;Glazed&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5005&quot;, &quot;type&quot;: &quot;Sugar&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5007&quot;, &quot;type&quot;: &quot;Powdered Sugar&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5006&quot;, &quot;type&quot;: &quot;Chocolate with Sprinkles&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5003&quot;, &quot;type&quot;: &quot;Chocolate&quot; },&#xD;&#xA;            { &quot;id&quot;: &quot;5004&quot;, &quot;type&quot;: &quot;Maple&quot; }&#xD;&#xA;        ]&#xD;&#xA;}" />
<AMJSON ACTIVITY="get_values" JSONOBJECT="donuts" PATH="batters.batter[1].type" RESULTDATASET="dataset" />