Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use json extractor to extract multiple parameter values at one time

Shulou Source: shulou.com Published: 2022-06-02 07:30:51 09月25日 Update

This article mainly explains "how to use the json extractor to extract multiple parameter values at one time", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the json extractor to extract multiple parameter values at a time" bar!

Json extractor extracts multiple values

The above is the response data. I need to extract both of these parameters and pass them to the request of the next interface, and add the json extractor.

About the parameters of json extractor:

Names of created variables: the name of the variable that receives the value. Multiple variables are separated by semicolons.

Json path:json path expressions, also separated by semicolons

Match no:0 is random; n takes the matching value;-1 matches all, and subsequent references take the Nth value with the variable name _ N.

Default values: the default value, which is taken when the value does not match

Above we can see that variables, expressions, and default values are separated by semicolons, so that they can be passed to the next interface!

Check whether the request data is the return value of the previous API:

If we need to match multiple parameters in the array, how should we extract it?

If we want to extract all the id from the interface and pass it to the next interface according to the situation we need, we can first debug it with jsonpath:

As you can see above, the jsonpath expression is $.data [*] .id, get all the id in the data of the corresponding data, and then pass it to the next id corresponding to the next API according to our needs:

Suppose we need the id of the second post in the array, then the input parameters of the next interface can be written as follows

Id2 represents the second, and {id_1} represents the first. Take the value according to the subscript. Similarly, we need different values of different parameters in the array, which can be combined with the values of the above parameters. The json extractor can write:

Thank you for your reading, the above is the content of "how to use json extractor to extract multiple parameter values at one time". After the study of this article, I believe you have a deeper understanding of the problem of how to use json extractor to extract multiple parameter values at one time. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Parameters multiple interfaces one-time variables between semicolons data arrays expressions learning differences representatives content situation subscript two that is posts ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn macOS Shulou Information Apple Shulou Tech Info