当前位置:网站首页>JMeter JSON extractor extracts two parameters at the same time
JMeter JSON extractor extracts two parameters at the same time
2022-07-03 06:52:00 【God】
Two interfaces A、B, Interface B Interface required A Two parameters returned , from A Get the return value of the same object at random orderType and orderformId,
Interface A The return value of :
{
"list": [
{
"orderType": "1",
"orderformId": "2562",
},
{
"orderType": "1",
"orderformId": "2546",
},
{
"orderType": "0",
"orderformId": "2430",
}
]
}
json Extractor parameters :

json path expressions:$.list[1].orderformId;$.list[1].orderType , In this way, only one fixed object can be specified ; and $.list[*].orderformId;$.list[*].orderType,Match No :0;0 The two objects selected are random , The values of the two extracted parameters are different from the same object .
Solutions :json Expression , Parameterize the array index , According to the interface A The size of the returned array , Generate random number , Pass in json expression .( There are many ideas : utilize json The extractor randomly selects an object , Reuse Bean Sell The code takes the value of two parameters ... Never tried. ).
utilize Bean Sell Read the return value of the interface , Use regular expressions to determine the number of objects (json Processing seems to be guided , lazy , Regular substitution ), Generate random numbers for a specified range , Save variables , for json The extractor uses .
Bean Sell Code :
import java.util.regex.Matcher;
import java.util.regex.Pattern;
data = prev.getResponseDataAsString();
subs = "\"orderType\"";
Pattern pattern = Pattern.compile(subs);
Matcher matcher = pattern.matcher(data);
int count=0;
while(matcher.find()){
count++;
}
int i = new Random().nextInt(count-1);
vars.put("i",i+"");//vars.put("","") No numbers , Convert to string
json path expressions To configure :$.list[${i}].orderformId;$.list[${i}].orderType.
Finished product pictures :








边栏推荐
- Software testing learning - day one
- 【无标题】5 自用历程
- 【5G NR】UE注册流程
- Dbnet: real time scene text detection with differentiable binarization
- Pytest -- write and manage test cases
- 10000小時定律不會讓你成為編程大師,但至少是個好的起點
- Realize PDF to picture conversion with C #
- Architecture notes
- [C /vb.net] convert PDF to svg/image, svg/image to PDF
- 【无标题】
猜你喜欢
![[5g NR] UE registration process](/img/e3/f881d51fba03010de8c45ea480f3f0.png)
[5g NR] UE registration process

Practice of enterprise ab/testing platform

2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)

2022年华东师范大学计科考研复试机试题-详细题解

These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products

SQL implementation merges multiple rows of records into one row

每日刷题记录 (十一)

VMware virtual machine C disk expansion

vmware虚拟机C盘扩容

On the practice of performance optimization and stability guarantee
随机推荐
Heap sort and priority queue
IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library
The essence of interview
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
Integration test practice (1) theoretical basis
Search engine Bing Bing advanced search skills
第8章、MapReduce 生产经验
Arctic code vault contributor
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Practical plug-ins in idea
[untitled] 8 simplified address book
方差迭代公式推导
RestHighLevelClient获取某个索引的mapping
Asynchronous programming: async/await in asp Net
[classes and objects] explain classes and objects in simple terms
Unit test notes