在JMeter中捕获值的正则表达式

gblwokeq  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(185)

在Jmeter中,想从下面的json响应代码中捕获POD的id。尝试了$.. result[*].id,它显示了所有的ID,包括Value 1,Value 2中的once。但我的要求只是捕获PODID,这样它就可以在下一个请求中传递。还有,是否可以将PODID保存在数组中,并在下一个请求中发送它们?

{
    "result": [
        {
            "Value1": {
                "name": "Random1145843",
                "id": "32f338ffce"
            },
            "parent": null,
            "capabilities": null,
            "configuration": null,
            "timeZone": "America\/New_York",
            
            "Value2": {
                "name": "Random1137530",
                "id": "0940c7a8d7"
            },
            "ready": "ready",
            "organization": {
                "name": "Randome42711",
                "id": "da54c68830"
            },
            "name": "PodId_50631",
            "host": null,
            "id": "PODID_50631",
            "state": {
                 "mil": "clear",
                "diagnostic": "clear",
                            },
            "status": {
                "estimated_weight
                    "value": {
                        "uom": "KG,
                        "value": 500.0
                    }
                   
                },
               
           {
            "Value1": {
                "name": "Random1145443",
                "id": "32f3385fce"
            },
            "parent": null,
            "capabilities": null,
            "configuration": null,
            "timeZone": "America\/New_York",
            
            "Value2": {
                "name": "Random1137530",
                "id": "0940c758d7"
            },
            "ready": "ready",
            "organization": {
                "name": "Randome42755",
                "id": "da54c65630"
            },
            "name": "PodId_506356,
            "host": null,
            "id": "PODID_506356",
            "state": {
                 "mil": "clear",
                "diagnostic": "clear",
                            },
            "status": {
                "estimated_weight
                    "value": {
                        "uom": "KG,
                        "value": 500.0
                    }
                   
                },
                     {
            "Value1": {
                "name": "Random1145653",
                "id": "32f338f564"
            },
            "parent": null,
            "capabilities": null,
            "configuration": null,
            "timeZone": "America\/New_York",
            
            "Value2": {
                "name": "Random1135630",
                "id": "0940c734
            },
            "ready": "ready",
            "organization": {
                "name": "Randome42756
                "id": "da54c68830"
            },
            "name": "PodId_34556,
            "host": null,
            "id": "PODID_34556",
            "state": {
                 "mil": "clear",
                "diagnostic": "clear",
                            },
            "status": {
                "estimated_weight
                    "value": {
                        "uom": "KG,
                        "value": 500.0
                    }
                 
]
}

字符串

js4nwp54

js4nwp541#

您正在使用..操作符,这意味着“深度扫描”,因此它将返回所有id属性值,无论它们位于何处。
您需要将id属性的提取限制为resultJSON array的直接子级。类似于:

result.*.id

字符串


的数据
更多信息:JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios

相关问题