gjson
gjson copied to clipboard
Retrieve field values with multiple conditions
For a sample payload like this:
{
"name": {"first": "Tom", "last": "Anderson"},
"age":37,
"children": ["Sara","Alex","Jack"],
"fav.movie": "Deer Hunter",
"friends": [
{"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
{"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
{"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
]
}
If we want to get the age of friend whose last name isMurphy
and first name is Dale
then what gjson expression will give that result.
I tried friends.#(last == "Murphy" && first == "Dale")#.age
but it gives an empty array in response.
@tidwall kindly help regarding this