需要从Jmeter中的此JSON中提取数据

问题描述:

我必须从Jmeter中的JSON数组中提取所有唯一标识",然后将这些值存储在数组中,以便以后我可以将其与每个控制器一起使用,以附加到另一个URL的尾部.

I have to extract all the "uniqueid" from this JSON array in Jmeter and then store these values in an array so that later I can use it with for each controller to append to the tail of another URL.

有人可以帮我在Jmeter中做到这一点吗?

Can anyone help me how to do this in Jmeter.

您的帮助将不胜感激.谢谢!

Your help would be appreciated. Thanks!

{"groups":[
{
  "categoryid": 4003,
  "name": "Agarbatti",
  "properties": [
    {
      "name": "Take Photo",
      "type": "image",
      "displaytype": "image",
      "mandatory": false,
      "uniqueid": "1149"
    }
  ]
},
{
  "categoryid": 4005,
  "name": "Cigarettes",
  "properties": [
    {
      "name": "Take Photo",
      "type": "image",
      "displaytype": "image",
      "mandatory": false,
      "uniqueid": "1150"
    }
  ]
},
{
  "categoryid": "1001",
  "name": "Remark",
  "properties": [
    {
      "name": "Remark",
      "type": "string",
      "displaytype": "edit",
      "uniqueid": "Remarks",
      "mandatory": "true"
    }
  ]
    }
  ]
  }

最好使用 JSONPath Extractor 可通过 JMeter插件使用(您需要带Libs Set的Extras).

It's better to use JSONPath Extractor available via JMeter Plugins (you'll need Extras with Libs Set).

因此,对您的数据遵循JSONPath表达式:

So on your data following JSONPath Expression:

$..uniqueid

将返回下一个结构:

["1149","1150","Remarks"]

请参见在JMeter中使用XPath提取器指南(向下滚动至有关更多详细信息和JSONPath食谱的信息,请参阅解析JSON").

See Using the XPath Extractor in JMeter guide (scroll down to "Parsing JSON") for more details and a kind of JSONPath cookbook.