JSONEncode
JSONEncode
The JSONEncode block is an operator, that allows to encode input arguments as attributes to JavaScript Object Notation (JSON) formatted string.
Arguments
Name | Appearance | Description |
---|---|---|
JSON attribute name to encode | Any number of user-configurable input arguments | Argument name will be encoded to output as JSON attribute name, and argument current value will be encoded as this JSON attribute value. |
Out | Predefined output argument | The JSON-formatted string |
Note: The arguments are encoded to the output JSON in the order they appear in the JSONEncode block. So if you prefer having them in different order you can re-order the arguments in the JSONEncode block.
Example
The following block diagram shows how to encode a JSON string like this:
{ "name": "temp", "value": 25.6 }
For that, 2 input arguments were added to the JSONEncode block (named name and value). Then, these arguments current values (and as for all operators, the argument values can be routed from any value object in CDP) will be used to encode and output the JSON string, as can be seen in the block diagram:
See also JSONEncoder, JSONDecode, and Argument.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.