JMeter--assertion of JSON response &json path espressions syntax

Source: Internet
Author: User

First, extract the content of the required assertion:

The response data is as follows: Join needs to extract the value of ID 90

{    "ID": -,    "name":"python",    "URL":"Http://www.v2ex.com/go/python",    "title":"Python",    "title_alternative":"Python",    "Topics":7428,    "stars":4776,            "Header":"This topic discusses a variety of Python language programming topics, including Django,tornado and other frameworks. Here is a place to help you solve practical problems. ",                "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 Add-post processor- add JSON extracror(this needs to learn a little bit about the syntax of JSON path espressions)--Get the value of ID 90

Read this web site to learn it: http://goessner.net/articles/JsonPath/

2. You can also use regular expressions to extract

"id":(. +?),

Second, assert the extracted value

sample-Assertion-Add JSON path assert (if you want to install this package ah AH)

Third, the JSON path espressions syntax learning

$: With object \ Element

@: current object \ Element

? (): Apply filter (script) expression

Practice it yourself ....

1{"Store": {2     " Book": [ 3{"category":"Reference",4         "author":"Nigel Rees",5         "title":"Sayings of the Century",6         " Price":8.957       },8{"category":"Fiction",9         "author":"Evelyn Waugh",Ten         "title":"Sword of Honour", One         " Price":12.99 A       }, -{"category":"Fiction", -         "author":"Herman Melville", the         "title":"Moby Dick", -         "ISBN":"0-553-21311-3", -         " Price":8.99 -       }, +{"category":"Fiction", -         "author":"J. R. R. Tolkien", +         "title":"The Lord of the Rings", A         "ISBN":"0-395-19395-8", at         " Price":22.99 -       } -     ], -     "Bicycle": { -       "Color":"Red", -       " Price":19.95 in     } -   } to}

$.store.book[*].author: Author of all books in the store (four authors)

$.. Author: All Authors

$.store.*: Everything in the store, including book and bicycle

$.store. Price: Prices of all things

$.. BOOK[2]: The third book

$..book[0,1] /$..book[:2] :前两本书

$.. Book[? ( @.isbn)]: Filter All books with ISBN number

$.. Book[? ( @.price<10)]: Filter All books that are cheaper than 10

$.. *: All elements in the XML document

JMeter--assertion of JSON response &json path espressions syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.