Coming Soon
HTML Comment | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||
Function: toJson()Converts a block of JSON data into a recordset which contains the attributes for each node. an object, such as an array or JSON string, to JSON. SyntaxjsonToItems(JSON String, JSON Path, LenienttoJson(object)
Examples
| |||||||||||||
JSON Path | String | The JSON Path expression is evaluated against the data provided by the JSON String. It determines which elements are extracted from the JSON. Defaults to “$” which matches the entire document. This must be passed in as a string i.e. encapsulated in quotes. | |||||||||||
Lenient | boolean | Lenient is a flag which determines whether to parse the JSON String leniently. Defaults to | |||||||||||
Insert excerpt | JSON Node | JSON Node | |||||||||||
name | JSONPathSyntax | ||||||||||||
nopanel | true |
Code Block |
---|
jsonToItems('{"data":[{"value":"foo"},{"status":"bar"}]}', '$.data', true) |
Returns
Code Block |
---|
// returns a record set
{"value" : "foo"}, { "value" : "bar"} |
Array Returned
Code Block |
---|
jsonToItems('{"data":[{"value":"foo"},{"status":"bar"}]}', '$.data', true).value |
Returns
Code Block |
---|
// returns an array of values*
[foo, bar] |
toJson(getCo) |
Returns JSON from a lookup with an array of company objects.
Code Block |
---|
{
"getCo" : [ {
"CompanyID" : 108,
"CompanyName" : "Romaguera Inc",
"Industry" : "Manufacturing"
}, {
"CompanyID" : 112,
"CompanyName" : "Becker and Sons",
"Industry" : "Manufacturing"
}, {
"CompanyID" : 398,
"CompanyName" : "Larson Inc",
"Industry" : "Manufacturing"
} ]
} |
Code Block |
---|
{
forEach(
$company, toJson(getCo).getCo, $company.CompanyName : $company
)
} |
- Returns JSON from a Lookup
- Loops over the getCo array to generate a property pair of $company.CompanyName mapped to the company object
- . Accessed original getCo array in that as a property. Looping over that and generating a property pair of $company.CompanyName mapped to the company object. The foreach returns a list of property pairs. Because their in the curly bracket they get composed into the JSON object
Code Block |
---|
{
"Romaguera Inc" : {
"CompanyID" : 108,
"CompanyName" : "Romaguera Inc",
"Industry" : "Manufacturing"
},
"Becker and Sons" : {
"CompanyID" : 112,
"CompanyName" : "Becker and Sons",
"Industry" : "Manufacturing"
},
"Larson Inc" : {
"CompanyID" : 398,
"CompanyName" : "Larson Inc",
"Industry" : "Manufacturing"
}
} |
Return JSON from Lookup
Creates a key/value pair of the CompanyName mapped to CompanyID
Code Block |
---|
{
forEach(
$company, toJson(getCo).getCo, $company.CompanyName : $company.CompanyID
)
} |
Returns
Code Block |
---|
{
"Romaguera Inc" : 108,
"Becker and Sons" : 112,
"Larson Inc" : 398
} |
Return JSON from Lookup
Creates a key/value pair of the CompanyName mapped to CompanyID
Code Block |
---|
{
forEach(
$company, toJson(getCo).getCo, $company.CompanyName : {$company,"CompanyName":toUpper($company.CompanyName)}
)
} |
Returns
Code Block |
---|
{
"Romaguera Inc" : {
"CompanyID" : 108,
"CompanyName" : "ROMAGUERA INC",
"Industry" : "Manufacturing"
},
"Becker and Sons" : {
"CompanyID" : 112,
"CompanyName" : "BECKER AND SONS",
"Industry" : "Manufacturing"
},
"Larson Inc" : {
"CompanyID" : 398,
"CompanyName" : "LARSON INC",
"Industry" : "Manufacturing"
}
} |