JSON Object - Add to

Declaration

<AMJSON ACTIVITY="add_to" JSONOBJECT="text" PATH="text" TYPE="text (options)" ADDTO="text (options)" NEWVALUE="text" ISNULL="True/False" />

Related Topics    

Description

Adds a value to an existing array within an existing Automate Desktop 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 Desktop 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
  • TYPE="array"
  • TYPE="boolean"
  • TYPE="number"
  • TYPE="Object_name"
  • TYPE="Object_string"
  • TYPE="text"
Specifies the type of value to add to the array. The available options are:
  • Array - Adds an array to the array.

  • Boolean - Adds a true or false boolean value to the array.

  • Number - Adds a numeric value to the array.

  • Object name - Adds an object to the array.
  • Object string - Adds an object string to the array.

  • Text - Adds a textual value to the array.

Where to add Text (options) Yes Start
  • ADDTO="start"
  • ADDTO="end"
  • ADDTO="index"

 

Specifies where in the array to add the value. The available options are:
  • Start - Adds the value to the start of the array.
  • End - Adds the value to the end of the array.
  • Index - Adds the value at the index number specified.
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)
  • NEWVALUE=""
  • NEWVALUE="[]"
  • NEWVALUE="[1,2,3]"
  • NEWVALUE="[{'field1': 'value1', 'field2': 1}, {'field1': 'value2', 'field2': 3}]"
The array value to add to the field.
Boolean value Text (options) Yes, if the Value type parameter is set to Boolean True
  • NEWVALUE="True"
  • NEWVALUE="False"
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
  • 0 (Number)

  • (Empty) (Text)

  • NEWVALUE="3"

  • NEWVALUE="jelly"

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)
  • NEWVALUE="{'field1': 'value1', 'field2': 1}"
  • NEWVALUE="{'field1': 'value1', 'field2': 100, 'field3': false, 'field4': [1, 2, 3], 'field5': { 'foo': 'bar' }}"
The object string to add to the array.
Set value to null True/False No False
  • ISNULL="True"
  • ISNULL="False"
If selected (True), the value is set to Null. This parameter is cleared (False) by default.

Description

Error Causes

On Error

Example

NOTE:
  • 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 adds the text value custard to the batters.batter array within an existing Automate Desktop JSON Object.

Copy
<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="add_to" JSONOBJECT="donuts" PATH="batters.batter" TYPE="text" ADDTO="start" NEWVALUE="custard" />