解析JSON陣列文件我想JSONPath解析這個:與JSONPATH
[
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4],
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
]
你能提供幫助的嗎?
解析JSON陣列文件我想JSONPath解析這個:與JSONPATH
[
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4],
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
]
你能提供幫助的嗎?
如果對象是:
[
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4],
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
]
然後"$[0]"
將返回:
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4]
而且"$[1]"
將返回:
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
你能做到兩層深爲好。 "$[0][4]"
將返回:
205
也可以將陣列的元件提取到的列表與"$[*]"
,這將返回2個元素的列表。第一個是:
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4]
,第二個是:
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
非常感謝,真的很有幫助。 – salem12 2012-02-15 20:05:29
使用DefiantJS,您可以搜索與XPath語法的JSON結構。該庫使用搜索功能擴展全局對象JSON。
在這種情況下,你可以寫這樣的東西;
var data = [
[50.4154134372953,-1.28486558931069,"CLASS B",9,205,0,"UK",431500382,3,4],
[50.3058858494047,-0.976070494820637,"CLASS B",9,239,0,"UK",2750350,21,2]
],
search = JSON.search(data, '//*/*/*');
看看這個小提琴; http://jsfiddle.net/hbi99/5NfeM/
這對我的作品
JsonPath.with(jsonResponse).PARAM( 「名」, 「的getName」)獲得( 「{的findAll一個 - > a.name ==名}」)。
_你想把它解析成什麼?語言? – ArjunShankar 2012-02-15 10:22:05
我想知道JSONPATH例如$。*獲取數組中的任何項目。 – salem12 2012-02-15 13:18:58
所以,你想使用JSONPath,其多種語言的實現可在http://code.google.com/p/json-path/和http://goessner.net/articles/JsonPath/ – ArjunShankar 2012-02-15 14:47:06