1、提取所須要斷言的內容:python
響應數據以下:加入須要提取id爲90的值正則表達式
{ "id" : 90, "name" : "python", "url" : "http://www.v2ex.com/go/python", "title" : "Python", "title_alternative" : "Python", "topics" : 7428, "stars" : 4776, "header" : "這裏討論各類 Python 語言編程話題,也包括 Django,Tornado 等框架的討論。這裏是一個可以幫助你解決實際問題的地方。", "footer" : null, "created" : 1278683336, "avatar_mini" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_mini.png?m=1501663676", "avatar_normal" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_normal.png?m=1501663676", "avatar_large" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_large.png?m=1501663676" }
一、sample添加-後置處理器-添加JSON Extracror(這裏面須要稍微學習下json path espressions的語法了)--獲得id的值90編程
本身看這個網址學習吧:http://goessner.net/articles/JsonPath/json
二、也能夠使用正則表達式提取框架
"id":(.+?),學習
2、斷言提取出來的值url
sample-斷言-添加json path assert(前提是要安裝這個包啊啊啊)spa
3、json path espressions的語法學習.net
$:跟對象\元素code
@:當前對象\元素
?():應用過濾器(腳本)表達式
仍是本身練習吧。。。。
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 }
$.store.book[*].author:商店全部書籍的做者(四個做者)
$..author :全部做者
$.store.* :商店全部的東西,包括book和bicycle
$.store..price :全部東西的價格
$..book[2] :第三本書
$..book[0,1] /$..book[:2] :前兩本書
$..book[?(@.isbn)] :用isbn編號過濾全部書籍
$..book[?(@.price<10)] :過濾全部比10更便宜的書
$..* :XML文檔中的全部元素