I have array of objects and I'd like to find an object by using a condition using a child element.
For example, i want to get the value of the firstName if the value of phoneNumbers.type is "iPhone"
[{
"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"
}
]
},
{
"firstName": "Kevin",
"lastName": "Johnson",
"age": 26,
"address": {
"streetAddress": "naist street",
"city": "Nara",
"postalCode": "630-0192"
},
"phoneNumbers": [
{
"type": "android",
"number": "0123-4567-8888"
},
{
"type": "office",
"number": "0123-4567-8910"
}
]
}
]
I tried this but it doesn't match to anything. $[?(@.phoneNumbers.type=='iPhone')].firstName