Examples
These examples show the functionality of JSON Read node.
Example 1: The use case is to set a flow or cache variable variables to the Person_ID, City and Full_Address of some record.
The input data
is:
{
"id": 123,
"name": "fred",
"address": {
"street": "101 Main St",
"city": "London"
}
}
and the Paths table is set as:
Path | Variable/Key |
---|---|
$.id | Person_ID |
$.address.city | City |
$.address | Full_Address |
If the Variable Scope is set to flow or cache variables it will set these 3 variables:
Path | Variable/Key |
---|---|
Person_ID | 123 |
City | London |
Full_Address | {"street": "101 Main St", "city": "London"} |
Note: If the path returns a JSON object or array, the value is the serialized form of that
object or array.
If the Output Content property is set to filter the input, then the output in this example will
be:
{
"Person_ID": 123,
"City": "London",
"Full_Address": {
"street": "101 Main St",
"city": "London"
}
}
Example 2: This example demonstrates the query expressions.
The use case is to set a flow variable to the mobile phone number of some record.
The
input data
is:
The
path expression to achieve this is:
{
"phones": [
{
"type": "mobile",
"number": "111-222-3333"
},
{
"type": "home",
"number": "444-444-5555"
}
]
}
Path | Variable/Key |
---|---|
$.phones[?(@.type == "mobile")].number | mobile |
This means in the "phones" array, find the object whose "type" field is "mobile" and then
return the "number" field from this object. This will result in this flow variable:
Name | Value |
---|---|
mobile | 111-222-3333 |
If the Output Content property is set to filter the input, then the output in this
example will be:
{
"mobile": "111-222-3333"
}