Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt
hiddentrue

jsonToItems (JSON, JSON Path, Lenient) Converts JSON to attribute items. Converts a block of JSON data into a recordset which contains the attributes for each node. 


Function: jsonToItems()

Converts a block of JSON data to a set of attributes. This can be useful if you need to extract the values from within JSON data.into a recordset which contains the attributes for each node. 

Syntax

jsonToItems(JSON String, JSON Path, Lenient)

ArgumentTypeDescription
JSON StringStringJSON string to be converted to attribute valuesrecordset.
JSON PathString

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.

Lenientboolean

Lenient is a flag which determines whether to pass parse the JSON String leniently. Defaults to false.

Insert excerpt
JSON Node
JSON Node
nameJSONPathSyntax
nopaneltrue

...

Examples

Record Set Returned

Code Block
jsonToItems('{"data":[{data:{status:'success'}}", "$..status", true)

Generates 

Code Block
TBC"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]

*The array results can be accessed using normal Array Handling Functions