Given the below Json input:
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
I need to select the author field if the author matches a given name for eg. Evelyn Waugh. I am struggling to write the JsonPath Expression for this. I tried the following with no success. Can anyone suggest the correct expression?
$.author?(@ == 'Evelyn Waugh')
$.?(@.author == 'Evelyn Waugh')
$..?(@.author == 'Evelyn Waugh')
I suppose you could do this:
But that's a terribly useless query and error prone if you'd ask me. It all goes to hell if there's another property with the author's name.
Frankly, you should just get the author and test if it's the name you're expecting. Don't try to force this to work, it's not meant to be used this way.