|
JSON Object - Add to |
Declaration
<AMJSON ACTIVITY="add_to" JSONOBJECT="text" PATH="text" TYPE="text (options)" ADDTO="text (options)" NEWVALUE="text" ISNULL="True/False" />
Description
Adds a value to an existing array within an existing 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 add a value to an array within an 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 containing the array to add the value to. |
Array to add to | Text | No | (Empty) | PATH="batters.batter" | Specifies the JSON path to the array to add the value to. To select an array, click Select array, and then from the dialog that appears, choose the desired array by clicking its hyperlink. |
Value type | Text (options) | Yes | Array |
|
Specifies the type of value to add to the array. The available options are:
|
Where to add | Text (options) | Yes | Start |
|
Specifies where in the array to add the value. The available options are:
|
Index | Text | Yes, if the Where to add parameter is set to Index | (Empty) | INDEX="1" | Specifies the index number to use to add the value to the array. The default index value is 0. This parameter becomes available and is required if the Where to add parameter is set to Index. |
Array value | Text | No | (Empty) |
|
The array value to add to the field. |
Boolean value | Text (options) | Yes, if the Value type parameter is set to Boolean | True |
|
Sets the boolean value of the field to True or False. |
Field value | Text | Yes, if the Value type parameter is set to Number or Text |
|
|
The numeric or textual value to add to the array. |
Object name | Text | Yes, if the Value type parameter is set to Object name | (Empty) | NEWVALUE="sprinkles" | The object to add to the array. |
Object string | Text | Yes, if the Value type parameter is set to Object string | (Empty) |
|
The object string to add to the array. |
Set value to 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 adds the text value custard to the batters.batter array within an existing 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="add_to" JSONOBJECT="donuts" PATH="batters.batter" TYPE="text" ADDTO="start" NEWVALUE="custard" />