当前位置:网站首页>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 :








边栏推荐
- C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
- Asynchronous programming: async/await in asp Net
- Error c2017: illegal escape sequence
- Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
- Unittest attempt
- 论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
- 利用C#实现Pdf转图片
- Code management tools
- 2022 cisp-pte (III) command execution
- Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
猜你喜欢

MySQL installation

Numerical method for solving optimal control problem (I) -- gradient method

Software testing learning - day 3

In depth analysis of reentrantlock fair lock and unfair lock source code implementation

DBNet:具有可微分二值化的实时场景文本检测

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库

Reading notes of "learn to ask questions"

The dynamic analysis and calculation of expressions are really delicious for flee

ssh链接远程服务器 及 远程图形化界面的本地显示

如何迁移或复制VMware虚拟机系统
随机推荐
【无标题】8 简易版通讯录
[Code] if (list! = null & list. Size() > 0) optimization, set empty judgment implementation method
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
数值法求解最优控制问题(一)——梯度法
Search engine Bing Bing advanced search skills
MySQL installation
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
Simple password lock
Resttemplate configuration use
Print time Hahahahahaha
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
Winter vacation work of software engineering practice
How can the server set up multiple interfaces and install IIS? Tiantian gives you the answer!
2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution
error C2017: 非法的转义序列
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
机械观和系统观的科学思维方式各有什么特点和作用
ssh链接远程服务器 及 远程图形化界面的本地显示
【无标题】5 自用历程