Reputation: 103
I've tried to extract the id value based on email value from the following json:
[
{"id":11,"username":"John","address":"London","email":"[email protected]"},
{"id":12,"username":"Piere","address":"Paris","email":"[email protected]"},
{"id":13,"username":"Anne","address":"Moscow","email":"[email protected]"},
]
My expression is
$..[?(@.email=='[email protected]')].id
It doesn't work. What is wrong with this expression?
Upvotes: 0
Views: 78
Reputation: 147
Your expression is correct. I think you need to correct your JSON data instead. There is a syntax error. This is the correct one:
[
{"id":11,"username":"John","address":"London","email":"[email protected]"},
{"id":12,"username":"Piere","address":"Paris","email":"[email protected]"},
{"id":13,"username":"Anne","address":"Moscow","email":"[email protected]"}
]
You can use this to validate your JSON first next time.
https://jsonformatter.curiousconcept.com/
You may also validate your expression here
Upvotes: 1