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