JSON binding examples
JSON can be addressed via the XPATH3 support for JSON using the maps and arrays operators.
See examples inline.
refresh has been done
{
"automobiles": [
{
"maker": "Nissan",
"model": "Teana",
"year": 2000
},
{
"maker": "Honda",
"model": "Jazz",
"year": 2023
},
{
"maker": "Honda",
"model": "Civic",
"year": 2007
},
{
"maker": "Toyota",
"model": "Yaris",
"year": 2008
},
{
"maker": "Honda",
"model": "Accord",
"year": 2011
}
],
"motorcycles": [{
"maker": "Honda",
"model": "ST1300",
"year": 2012
}]
}
The car maker of the day:
{?automobiles?*[current-date() => day-from-date() mod 5]?maker}
Repeating over JSON
-
Maker: {?maker} Model: {?model} Year: {?year}- {let $maker := ?maker =>trace() return if(instance('instance1')?motorcycles?*[?maker = $maker]=> exists()) then "Also makes motorcycles" else "Makes no motorcycles"}