Jmeter- Json提取器
以如下json串为例子:
{ "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 } }, "expensive": 10 }
JsonPath 结果:
$.store.book[*].author 表示所有书籍的作者。
$..author 表示所有作者
$.store.* 所有东西--所有书籍和自行车。
$.store..price 所有东西的价格
$..book[2] 第三本书
$..book[-2] 倒数第二本书
$..book[0,1] The first two books
$..book[:2] 索引为0到2(不含2)的所有书籍
$..book[1:2] 索引为1到2(不含2)的所有书籍
$..book[-2:] 最后两本书
$..book[2:] 索引为2及其往后的所有书籍。
$..book[?(@.isbn)] 携带isbn号的所有书籍 an ISBN number
$.store.book[?(@.price < 10)] 商店中价格低于10的所有书籍。
$..book[?(@.price <= $['expensive'])] 所有非 "expensive"的书籍
$..book[?(@.author =~ /.*REES/i)] 所有匹配正则表达式(忽略大小写)的书籍
$..* 返回所有东西
$..book.length() 书籍数量
欢迎各路侠客多多指教^_^