博小園 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的書 |
| $..* | 所有元素 |
