我尝试根据以下json中的电子邮件值提取id值:
[
{"id":11,"username":"John","address":"London","email":"john@test.com"},
{"id":12,"username":"Piere","address":"Paris","email":"piere@test.com"},
{"id":13,"username":"Anne","address":"Moscow","email":"anne@test.com"},
]
我的表达是
$..[?(@.email=='anne@test.com')].id
它不起作用。这个表达有什么问题?
答案 0 :(得分:1)
你的表情是正确的。我认为您需要更正您的JSON数据。存在语法错误。 这是正确的:
[
{"id":11,"username":"John","address":"London","email":"john@test.com"},
{"id":12,"username":"Piere","address":"Paris","email":"piere@test.com"},
{"id":13,"username":"Anne","address":"Moscow","email":"anne@test.com"}
]
您可以使用它来下次验证您的JSON。
https://jsonformatter.curiousconcept.com/
您也可以在此处验证您的表达