I am trying to build a single JSONPath query which will test existence of two or more paths.
Let's consider the following sample document:
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"phoneNumbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888"
},
{
"type" : "home",
"number": "0123-4567-8910"
}
]
}
So far I have found:
$..[firstName,lastName,type]
And get all of these elements from the entire document.
But, what I need is to check two different paths, e.g.:
$.firstName
$.address.city
Can this be done with a single JSONPath query? I cannot write anything like:
$.[firstName,address.city]
With XML and XPath I could write:
/person/firstname | /person/address/city
and get a union of all matching XML elements.
Can I do the same with JSONPath?