JPath
To query and access elements within a JSON document we have created a language which is in similar nature to XPath, the language used to query an Xml document.
Each level of nesting either of objects or arrays requires the name of the property followed by a slash.
To access an array the property name is followed by an opening and closing square brackets. Presently this syntax only allows you to access the first element within the array, with on method to access specific elements.
Example
{
"order_number": "1028",
"token": "3b26b5ecd992012ac7a5e609f2d3379e",
"customer": {
"email": "[email protected]",
"first_name": "Terry",
"last_name": "Henry"
},
"site": "FR011",
"shopifyid": 126627282,
"line_items": [
{
"quantity": 1,
"price": 10.22
},
{
"quantity": 2,
"price": 20.44
}
]
}
/order_number
- Would return “1208”
/customer/first_name
- Would return “Terry”
/line_items[]/quantity
- Would return the quantity value of the first element in the line_items array.