execute json xpath(key a, expression b, array as text c, ignore exception d)
Group |
Performs an XPath-like query b against an existing JSON object (under key a) in the internal cache. See function parse json and add to cache(data a, key b).
The result is either a string or a number (i.e. the size of the list/map if parameter c is set to false).
Parameter Description
Parameter |
Description |
a |
The key name of the JSON object in the cache. |
b |
The query. See https://github.com/json-path/JsonPath. |
c |
true will return JSON text, false will return the size of the array/list. Does not apply for maps. |
d |
If true, exceptions are ignored and an empty string is returned. Default: <empty> (== false). |
Examples
File:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
Expression: $.store.book[*].author
Array as text: false
Result: 4 (author found four times)
Expression: $.store.book[*].author
Array as text: true
Result: ["Nigel Rees","Evelyn Waugh","Herman Melville","J. R. R. Tolkien"]
Expression: $..store.book[0]
Array as text: true
Result: [{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95}]
File:
{"date_as_long": 1411455611975}
Expression: $['date_as_long']
Array as text: true or
Result: 1411455611975 (as string)