|
JSON Object - Add field |
Declaration
<AMJSON ACTIVITY="add_field" JSONOBJECT="text" PATH="text" NEWFIELD="text" TYPE="text (options)" NEWVALUE="text or nummber" ISNULL="True/False" />
Description
Adds a field with a defined field type to 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 field to 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 to add the field to. |
Object to add to (leave blank to add to root) | Text | Yes | (Empty) |
|
Specifies the JSON path of the object to add the field to. The path can add a field to the root, to an object, or to an array. To select an object, click Select object, and then from the dialog that appears, choose the desired object by clicking its hyperlink. |
Field name | Text | Yes | (Empty) | NEWFIELD="filling" | The name of the field to add to the JSON Object. |
Field type | Text (options) | Yes | Array |
|
Specifies the type of field to add to the JSON Object. The available options are:
|
Array value | Text | Yes, if the Field type parameter is set to Array | (Empty) |
|
The array value to add to the field. |
Boolean value | True/False | Yes, if the Field type parameter is set to Boolean | True |
|
Sets the boolean value of the field to true or false. |
Field value | Text | Yes, if the Field type parameter is set to Number or Text |
|
|
The numeric or textual value to add to the field. |
Object name | Text | Yes, if the Field type parameter is set to Object name | (Empty) | NEWVALUE="sprinkles" | The object to add to the field. |
Object string | Text | Yes, if the Field type parameter is set to Object string | (Empty) |
|
The object string to add to the field. |
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 a new text-based field to the root of 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="add_field" JSONOBJECT="donuts" NEWFIELD="filling" TYPE="text" NEWVALUE="jelly" />