博小园 2019-01-19
| JSON Path | 描述 |
| $ | 表示根元素 |
| @ | 表示当前节点 |
| . | 表示子节点 |
| .. | 选择所有符合条件的节点 |
| * | 所有节点 |
| [] | 迭代器标识,如数组下标 |
| [,] | 支持迭代器中多选 |
| [start:end:step] | 数组切片 |
| ?() | 支持过滤 |
| () | 支持表达式计算 |
- {
"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
},
{
"category":"fiction",
"author":"Herman Melville",
"title":"Moby Dick",
"isbn":"0-553-21311-3",
"price":8.99
},
{
"category":"fiction",
"author":"J. R. R. Tolkien",
"title":"The Lord of the Rings",
"isbn":"0-395-19395-8",
"price":22.99
}
],
"bicycle":{
"color":"red",
"price":19.95
}
}
}
| 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的书 |
| $..* | 所有元素 |
