jmeter之--斷言json響應&json path espressions的文法

來源:互聯網
上載者:User

標籤:編程   set   .com   image   ons   ini   path   解決   安裝   

一、提取所需要斷言的內容:

響應資料如下:加入需要提取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"}

 1、sample添加-後置處理器-添加JSON Extracror(這裡面需要稍微學習下json path espressions的文法了)--得到id的值90

自己看這個網址學習吧:http://goessner.net/articles/JsonPath/

 

2、也可以使用Regex提取

"id":(.+?),

 

二、斷言提取出來的值

sample-斷言-添加json path assert(前提是要安裝這個包啊啊啊)

 三、json path espressions的文法學習

$:跟對象\元素

@:當前對象\元素

?():應用過濾器(指令碼)運算式

 

還是自己練習吧。。。。

 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.9912       },13       { "category": "fiction",14         "author": "Herman Melville",15         "title": "Moby Dick",16         "isbn": "0-553-21311-3",17         "price": 8.9918       },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.9924       }25     ],26     "bicycle": {27       "color": "red",28       "price": 19.9529     }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文檔中的所有元素

 

 

jmeter之--斷言json響應&json path espressions的文法

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.