{
"responseCode": "200",
"data": {
"sequence": 1,
"used": true,
"sensingTags": [
{
"code": "LED",
"value": 1,
"updatedOn": 1587557350251
}
]
}
}
我的目标是使用jsonPath从这个json中获取updateOn值,就像这样
1587557350251
我以为下面的jsonPath可以工作,但它只提取了空列表。
$..sensingTags[?(@.code == 'LED')][0].updatedOn
我想知道如何像下面这样提取值。
{
"code": "LED",
"value": 1,
"updatedOn": 1587557350251
}
不像这个。
[
{
"code" : "LED",
"value" : 1,
"updatedOn" : 1587557350251
}
]
根据 "数据":{ "序列": 1, "使用": true, "传感标签": [ { "代码": "LED", "值": 1, ... 使用JSONPath从JSON对象中获取单个值JsonPath总是返回一个数组(或一个 false
)在这一点上...
你能做的最好的就是把它处理成一个数组updateOn,然后简单的总是抓取第一个值。
$..sensingTags[?(@.code == 'LED')].updatedOn