|
JSON Object - To text |
Declaration
<AMJSON ACTIVITY="json_to_text" JSONOBJECT="text" PATH="text" RESULTVARIABLE="text" />
Description
Converts an Automate JSON Object to text.
Practical Usage
JSON is primarily used to transmit data between a server and web application, as an alternative to XML. Use this activity to convert an Automate JSON Object to text.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
JSON Object name | Text | Yes | (Empty) | JSONOBJECT="donuts" | The name of the JSON Object to convert to a JSON-formatted string. |
JSON Object to convert | Text | No | (Empty) | PATH="donuts" | Specifies the main or nested JSON Object to convert to text. To select an object, click Select object, and then from the dialog that appears, choose the desired object by clicking its hyperlink. |
Populate variable with JSON text | Text | Yes | (Empty) | RESULTVARIABLE="varName" | The name of an existing variable to use to populate with the converted text. |
Example
NOTE:
- 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 selects a nested JSON Object from the main Automate JSON Object and then populates a variable with the results.
Copy
<AMVARIABLE NAME="varName" />
<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="json_to_text" JSONOBJECT="donuts" PATH="batters.batter[1]" RESULTVARIABLE="varName" />