{"people": [{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]}
{"people": [{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]}
提供类似以下结构的JSON:
{"people": [{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]}
{
"name":"Some Guy",
"emails":[
{
"description":"primary",
"status":"UNVERIFIED",
"email":"first@first-email.com"
},
{
"description":"home",
"status":"VERIFIED",
"email":"second@second-email.com"
},
{
"description":"away",
"status":"VERIFIED",
"email":"third@third-email.com"
}
]
}
我希望能够使用一个JSONPath表达式来获取状态为VERIFIED
的第一个电子邮件,如果没有,则只获取数组中的第一个电子邮件。因此,鉴于上面的示例,结果将是second@second-email.com
。给定以下示例:
{
"name":"Some Guy",
"emails":[
{
"description":"primary",
"status":"UNVERIFIED",
"email":"first@first-email.com"
},
{
"description":"home",
"status":"UNVERIFIED",
"email":"second@second-email.com"
}
]
}
结果将会是first@first-email.com
。
使用JSONPath表达式是否可行?