JSON Object - Get size
Declaration
<AMJSON ACTIVITY="get_size" JSONOBJECT="text" PATH="text" RESULTVARIABLE="text" />
Description
Obtains the size of an existing array within an existing Automate Desktop JSON Object and then populates a variable with the result.
Practical usage
JSON is primarily used to transmit data between a server and web application, as an alternative to XML. Use this activity to get the size of an existing array within an existing an Automate Desktop JSON Object and store the results in a variable.
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. |
Array to get size of | Text | No | (Empty) | PATH="batters.batter" | Specifies the JSON path to the array. To select an array, click Select array, and then from the dialog that appears, choose the desired array by clicking its hyperlink. |
Store size to variable | Text | Yes | (Empty) | RESULTVARIABLE="size" | The name of the variable to use to store the size of the array. |
Example
- 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 obtains the size of the batters.batter array within an existing Automate Desktop JSON Object, and then stores the result in a variable.
<AMVARIABLE NAME="size" VALUE="%%" />
<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="get_size" JSONOBJECT="donuts" PATH="batters.batter" RESULTVARIABLE="size" />