JSON Decode Node
The JSON Decode Node allows a workflow to decode a JSON string into an object on the payload.
Node Properties
While using this node, you must configure the following properties:
Configuration
There are two configuration properties for the JSON Decode Node…
- Source String Path: the payload path to the string to decode
- Destination Path: the payload path at which to store the result object
Note: It is possible for both paths to be the same, in which case the JSON string will be replaced by the decoded object.
Error Configuration
In the case that the provided JSON string fails to parse, there are two possible options for how to handle the error.
- Error the workflow: Halt the workflow at this node, preventing further execution.
- Store JSON error at payload path: Configure a payload path at which to store the error.
Note: For edge workflows, this option is only available on edge version 1.14.0 or higher. On older versions, the workflow will always halt on errors.
Read more about handling errors from this node below.
Node Example
In the above example, the workflow will decode the string at the working.jsonString
path and place the resulting object at the working.jsonObject
path. So, for example, given the following payload:
{
"working": {
"jsonString": "{\"messageBody\":[12,24],\"name\":\"Trigger52\"}"
},
"time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
...
}
The payload after execution of the JSON Decode Node would look like:
{
"working": {
"jsonString": "{\"messageBody\":[12,24],\"name\":\"Trigger52\"}",
"jsonObject": {
"messageBody": [
12,
24
],
"name": "Trigger52"
}
},
"time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
...
}
Node Errors
In the case that the provided JSON string fails to parse, there are two possible options. You can either error the workflow, or you can store the error at a path on the payload.
Below is an example of an error stored on the payload:
{
"working": {
"jsonError": {
"message": "Invalid JSON source: data.jsonString",
"type": "JSON_DECODE_NODE_ERROR"
},
"jsonString": "notJson"
},
"time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
...
}
Related Nodes
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.