当前位置:网站首页>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 :
边栏推荐
- Dbnet: real time scene text detection with differentiable binarization
- [open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
- Software testing learning - day 3
- Class and object summary
- Simple password lock
- Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
- Floating menu operation
- 论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
- Scroll view specifies the starting position of the scrolling element
- 爬虫代码基础教学
猜你喜欢
Software testing learning - day one
Summary of remote connection of MySQL
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
SQL implementation merges multiple rows of records into one row
MySQL installation
Sorting out the core ideas of the pyramid principle
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
10000小时定律不会让你成为编程大师,但至少是个好的起点
Journal quotidien des questions (11)
随机推荐
IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library
La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
centos php7.3安装redis扩展
爬虫代码基础教学
VMware virtual machine C disk expansion
Dbnet: real time scene text detection with differentiable binarization
Yolov3 learning notes
2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
Numerical method for solving optimal control problem (I) -- gradient method
instanceof
【LeetCode】Day93-两个数组的交集 II
[LeetCode]404. Sum of left leaves
[untitled]
Modify MySQL password
Summary of remote connection of MySQL
A letter to graduating college students
error C2017: 非法的转义序列
每日刷题记录 (十一)
Scroll view specifies the starting position of the scrolling element
【无标题】