Encode JSON - Sandbox
The Encode JSON action parses a JSON
template and populates the identified variables into an
output JSON string.
The Encode JSON action is now part of the base runtime product
Starting with the 18.2.3 release, the Encode JSON action is now part of the base runtime product.
- For information on the base runtime verion of the action, see Encode JSON.
For releases 18.2.2 and earlier, this action is
part of the Technology Preview Extension, which is
also referred to as the sandbox
package.
- For information on obtaining and installing the extension, see Technology Preview Extension.
Parameter descriptions
Parameter | Description |
---|---|
JSON Template | A JSON structure that will generate
variables to be encoded. The JSON
Template contains sample values that
show the variables and their types.
Each JSON variable element contains the
following:
An array of values is indicated by enclosing the value within[ ] characters. If a JSON Object contains an array of values another variable is generated to specify the size. |
Clicking the multi-line input icon allows you to view or edit the JSON Template.
Select the Use Advanced Properties to view the advanced properties. The following table describes the advanced properties parameters:
Parameter | Description |
---|---|
Maximum String Size | The maximum string size for strings that are in an array. The default Maximum String Size is 256. The range is between 10 and 1024. |
Maximum Array Size | The maximum size of an array. The default Maximum Array Size is 256. The range is between 1 and 256. |
Structure Delimiter Character | The default character used to delimit between the structure name and the variable within the structure is the # character. This parameter can be used to change this delimiter to another character. |
Array Size Identifier | The string which is appended to the end of all array size variables. The default Array Size Identifier is " Size" but that can be changed in case of name collision or preference. |
Each member within a JSON structure must be represented at runtime as a unique variable. A unique name is created to identify each member in the structure. The name consists of the structure name, followed by a delimiter character, followed by the member name.
Input tab
The Input tab contains all the variables parsed from the JSON Template.
Parameter | Description |
---|---|
Input Map Variables | JSON Objects with values are identified from the JSON Template and will be added as input variables. |
Output tab
The Output tab contains the JSON Output string as well as a resultStatus and resultMessage for debugging.
Parameter | Description |
---|---|
JSON Output | The JSON string which is the result of the encoding using the JSON Template and the values from the Input tab variables. |
resultStatus | An INT4 variable that will contain the completion status of this action. A value of zero indicates the JSON Input value is successfully parsed and matched the template identified in the JSON Template field. A non-zero value indicates the action is not successful. |
resultMessage | A String variable of 64 characters that will provide further information when the resultStatus is non-zero. |
- NULL values in the template are currently not supported. If there is a null value, it is ignored.
- Floating points must not be whole numbers such as "1.0". This will register as an integer. The user must enter some decimal value like "1.9". This is a limitation of the library used.
- This action does not support arrays and objects that are nested too deeply because this would result in a stack overflow. To prevent this the action limits the depth to JSON_NESTING_LIMIT which is 1000 by default but it is possible to change it at compile time.
- The action template does not support strings that contain the zero character '\0' or \u0000. This is due to the fact that those strings are zero terminated.
- This action does not officially
support any
double
implementations other than IEEE754 double precision floating point numbers. The maximum length of a floating point literal that the action supports is currently 63 characters.
Example
The following is an example JSON template
that contains a mix of data types and includes
an array of a structure named
INSTALLED_PART.
The array contains two elements with members
named
partName, partSerialNumber, partStatus,
and timestamp.
{
"INSTALLED_PART": [{
"partName": "HEADLIGHT PART",
"partSerialNumber": "PART1",
"partStatus": "1",
"timestamp": "2013-10-02 14:34:31.537"
},
{
"partName": "TEST PART",
"partSerialNumber": "PART2",
"partStatus": "1",
"timestamp": "2013-10-0214:34:34.056"
}
],
"PRODUCT_TYPE": "FRAME",
"PROCESS_POINT_ID": "PP10483",
"PRODUCT_ID": "5KBRL5898EB801655",
"TEXT_ID": "0410",
"TIMESTAMP": "2013-10-02 13:22:42"
}
The following is the Input tab that
corresponds to the above JSON template. The
default value of 256 is used for
the Maximum String Size.
The # character is used to
delimit the structure name and the structure
member name.