本文介绍了Jmeter 提取字段/解析 JSON 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在响应正文中有以下 JSON 格式

[{"名称" : "Prashant",城市":悉尼"},{"名称" : "瑜珈",城市":伦敦"}]

检查此数组是否有任何记录的更好方法是什么,如果有,请给我第一个数组索引的名称".我正在为 jMeter 使用 jp@gc JSON 提取器插件.

是否可以使用插件来解析它,还是需要使用正则表达式来解析?

解决方案

使用 项目的 3 位开发人员将为您提供帮助.

I have following JSON format in response body

[
    {
        "Name" : "Prashant",
        "City" : "Sydney"
    },
    {
        "Name" : "Yogi",
        "City" : "London"
    }
]

What is the better way for checking if this array has any records and if yes give me "Name" for first array index. I am using jp@gc JSON extractor plugin for jMeter.

Is it possible to parse this using a plugin or do I need to do it using regular expressions?

解决方案

Using Ubik Load Pack JSON plugin for JMeter which is part of JMeter since version 3.0 (donated plugin) and called JSON Extractor, you can do it:

Test Plan overview:

ULP_JSON PostProcessor:

If Controller:

And here is the run result:

So as you can see it is possible with plain JMeter

If you're looking to learn JMeter, this book by 3 developers of the project will help you.

这篇关于Jmeter 提取字段/解析 JSON 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 14:03