| JSON Path |
描述 |
| $ |
表示根元素 |
| @ |
表示当前节点 |
| . |
表示子节点 |
| .. |
选择所有符合条件的节点 |
| * |
所有节点 |
| [] |
迭代器标识,如数组下标 |
| [,] |
支持迭代器中多选 |
| [start:end:step] |
数组切片 |
| ?() |
支持过滤 |
| () |
支持表达式计算 |
1 { "store": {
2 "book": [ 3 { "category": "reference", 4 "author": "Nigel Rees", 5 "title": "Sayings of the Century", 6 "price": 8.95 7 }, 8 { "category": "fiction", 9 "author": "Evelyn Waugh", 10 "title": "Sword of Honour", 11 "price": 12.99 12 }, 13 { "category": "fiction", 14 "author": "Herman Melville", 15 "title": "Moby Dick", 16 "isbn": "0-553-21311-3", 17 "price": 8.99 18 }, 19 { "category": "fiction", 20 "author": "J. R. R. Tolkien", 21 "title": "The Lord of the Rings", 22 "isbn": "0-395-19395-8", 23 "price": 22.99 24 } 25 ], 26 "bicycle": { 27 "color": "red", 28 "price": 19.95 29 } 30 } 31 }
| JSONPath |
结果 |
| $.store.book[*].author |
书店所有书的作者 |
| $..author |
所有的作者 |
| $.store.* |
store的所有的元素,包括book和bicyle |
| $.store..price |
store所有东西的price |
| $..book[2] |
第三本书 |
| $..book[(@.legnth-1)] |
最后一本书 |
| $..book[0,1] |
前面的两本书 |
| $..book[:2] |
前面的两本书 |
| $..book[?(@.isbn)] |
过滤出所有的包含isbn的书 |
| $..book[?(@.price<10)] |
过滤出价格低于10的书 |
| $..* |
所有元素 |