當REST服務響應返回的JSON數組如何處理:對e.g:如何使用JsonPath訪問JSON數組響應?
[{"boolField":true,"intField":991, "StringField":"SampleString"},
{"boolField":false, "intField":998, "StringField": "SampleString2"}]";
所有博客&的例子,我所看到的沒有處理上述情況。例如,我通過http://goessner.net/articles/JsonPath/表達式語法,但找不到解決方案。
例如下面的JSON,如果我想獲得所有的作者,我可以使用$.store.book[*].author
或$..author
{ "store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}]}
}
但是,如果REST服務響應返回象下面這樣,那麼如何讓所有的作家從列表中刪除
[
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
]
@josephconley,它的工作。謝謝。 – parishodak
'$ .. author' does not work。 – parishodak
我在https://jsonpath.curiousconcept.com/測試了它,並獲得了作者數組,並得到了什麼結果? – josephpconley