Application icon

Add Item to Container Array

This statement is used to add an item to the end of the array referenced in the directed path field. The target of the directed path field must refer to an Array. You must select a data type to identify how the data field is formatted.

With the exception of the JSON Text datatype, all text fields in the statement can contain any of the escape sequences defined in Escape Sequences.

The action test state will be set to true if there are no errors. The action test state will be false if any errors occurred. Named variable Container Error will contain the errror text. If the Stop action on error option is enabled, the action will be terminated with an error message in the case of an error.

The available data types are:

JSON Text
The JSON text is specified as being contained in a named variable or is directly entered in a resizable multi line edit panel. Note that only Array and Object items can be specified.

When using a named variable, the named variable field can contain any of the escape sequences defined in Escape Sequences. It is assumed that the named variable's content is properly formatted and escaped JSON text. This may be downloaded JSON returned by the Open URL statement.

When specifying JSON text directly you must select the Edit JSON button to edit the text in a resizable multi line edit panel. More information on this panel can be found here.

Referenced Item
The item path field contains a directed path to the item to be added. The added item is copied. Therefore any item can be added ... even the entire destination container.

Empty Array
This is equivalent to adding JSON Text with the json field set to []

Empty Object
This is equivalent to adding JSON Text with the json field set to {}

Null
A Null item is added.

Number
A Number item is added represented by the number in the number field. At runtime the data must resolve to be a number or the action test state will be set to false. An empty number field will be treated as 0.

String
A String item is added represented by the possibly empty text in the string field.

Boolean
A Boolean item is added. The boolean field may contain true or false (case insensitive). Optionally an integer may be used to specify the value. 0 represents false and any other integer value represents true. An empty boolean field will be treated as false.

Items in Array
The array path field must be a directed path to an array in a container. All items in the array at array path are added to the end of the array specified in the directed path field.

Items in List
The list field is a named variable which contains the list. If a list delimiter is not specified, the default list delimiter (\~) is assumed. All items in the list are added to the end of the array specified in the directed path field. All added items will be strings.

Example:

{
  "genres" : [
    "blues",
    "rock",
    "jazz",
    "classical"
  ]
}

Assume the above JSON text is in a container named sample. The following statement...

Add string 'country' to the container array at 'sample.genres'

will result in the following:

{
  "genres" : [
    "blues",
    "rock",
    "jazz",
    "classical",
    "country"
  ]
}

Subsequently executing the rather silly:

Add string 'sample.genres' to the container array at 'sample.genres'

will result in:

{
  "genres" : [
    "blues",
    "rock",
    "jazz",
    "classical",
    "country",
    "blues",
    "rock",
    "jazz",
    "classical",
    "country"
  ]
}


Containers

Directed Paths