JSON Path表达式

JSONPath详解

 

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..pricestore所有东西的price
$..book[2]第三本书
$..book[(@.legnth-1)]最后一本书
$..book[0,1]前面的两本书
$..book[:2]前面的两本书
$..book[?(@.isbn)]过滤出所有的包含isbn的书
$..book[?(@.price<10)]过滤出价格低于10的书
$..*所有元素

转载于:https://www.cnblogs.com/zhuzhaoli/p/10290443.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值