英文:
Extract random ID from Json with multiple conditions
问题
请帮我用JMeter Json提取器提取具有以下条件的随机rid:
- rid不等于0
- Name以"Test"开头
例如:对于以下json,我们应该检索rid为3或7,因为它们不等于0并且Name以"Test"开头。
{
"Documents": [
{
"rId": 0,
"Name": "Test_Sunil"
},
{
"rid": 3,
"Name": "Test_Sunil"
},
{
"rid": 7,
"Name": "Test_Kumar"
},
{
"rid": "0",
"Name": "Unknown"
}
]
}
英文:
Can you please help me with a JMeter Json extractor to extract
Random rid with below conditions
rid !=0 and Name starts with "Test"
For Example: for below json we should retrieve rid 3 or 7 as it is not 0 and Name starts with "Test"
{
"Documents": [
{
"rId": 0,
"Name": "Test_Sunil",
},
{
"rid": 3,
"Name": "Test_Sunil",
},
{
"rid": 7,
"Name": "Test_Kumar",
}
{
"rid": "0",
"Name": "Unknown",
}
]
}
答案1
得分: 0
你可以使用JSON Extractor和以下的JSONPath表达式:
$..Documents[?(@.rId != 0 && @.Name=~ /Test.*/)].rid
完整配置:
之后可以将提取的值作为${rid}
在需要的地方引用。
英文:
You can go for JSON Extractor and the following JSONPath expression:
$..Documents[?(@.rId != 0 && @.Name=~ /Test.*/)].rid
Full configuration:
Refer extracted value as ${rid}
later on where required.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论