|
JSON Object - Set values |
Declaration
<AMJSON ACTIVITY="set_values" JSONOBJECT="text"><NEWVALUE ISNULL="True/False" PATH="text" VALUE="text" /></AMJSON>
Description
Sets specific field values inside an already or newly defined Automate JSON Object.
Practical Usage
JSON is primarily used to transmit data between a server and web application, as an alternative to XML. Use this activity to set a value inside an already defined or newly defined Automate JSON Object.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
JSON Object name | Text | Yes | (Empty) | JSONOBJECT="donuts" | The name of the JSON Object to set the value in. |
Field | Text | Yes | (Empty) |
|
The name of the field to set within the JSON Object. The path can set a field in the root, in an object, or in an array. To set a value, click Set values, and then from the dialog that appears, enter the value in the desired box. When finished, click OK. |
Value | Text | Yes | (Empty) | VALUE="Berry" | The value to set within the field in the JSON Object. |
Null | True/False | No | False |
|
If selected (True), the value is set to Null. This parameter is cleared (False) by default. |
Example
- 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 sets the Blueberry value in the batters.batter array to Berry within an Automate JSON Object.
<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="set_values" JSONOBJECT="donuts"><NEWVALUE ISNULL="False" PATH="batters.batter[2].type" VALUE="Berry" /></AMJSON>