Working with JSON in JMeter

Source: Internet
Author: User
When we do the HTTP interface test, the returned data are JSON string, JMeter itself is not support directly processing JSON string, if you want to get to the return results specified in the value,
Must be obtained through regular expression, the regular expression is troublesome, write wrong to get the value, we all know that JSON is key-value so to save value, that jmeter inside can directly through key to value it
, so it's not as troublesome as regular expressions. If you want to take the value directly from the key, JMeter official has a JSON path extractor plug-in, loaded it can be directly processed JSON, with key to take the value.
The plug-in is: http://jmeter-plugins.org/wiki/JSONPathExtractor/, after downloading, the Lib folder into the JMeter directory is OK. Open JMeter, where the JMeter is version 3.0, create a new call interface HTTP request, and then add the post processor, you can see the JSON path extractor this plug-in, such as:

 

How to use it, for example, I just called the interface to get the user information, I want to get to the first user_id, the return JSON is this:

Analysis of this JSON string, the UserID in the info this list is stored, take the first userid, it is necessary to take the value of info, and then take the first element of info, that is, user information, and then take to the UserID.
The JSON path extractor uses $ to represent the return value of the original interface, taking values such as:

Working with JSON in JMeter

Related Article

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.