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" />

Related Topics    

Description

Adds a field with a defined field type to 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 field to 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 to add the field to.
Object to add to (leave blank to add to root) Text Yes (Empty)
  • PATH=""
  • PATH="fillings"
  • PATH="fillings.filling[2]"
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
  • TYPE="array"
  • TYPE="boolean"
  • TYPE="number"
  • TYPE="Object_name"
  • TYPE="Object_string"
  • TYPE="text"
Specifies the type of field to add to the JSON Object. The available options are:
  • Array - Adds an array to the field.

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

  • Number - Adds a numeric value to the field.

  • Object name - Adds an object to the field.

  • Object string - Adds an object string to the field.

  • Text - Adds a textual value to the field.

Array value Text Yes, if the Field type parameter is set to Array (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 True/False Yes, if the Field 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 Field 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 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)
  • 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 field.
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 a new text-based field to the root of an 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_field" JSONOBJECT="donuts" NEWFIELD="filling" TYPE="text" NEWVALUE="jelly" />