来自另一个数组的JsonPath条件| Jmeter

hkmswyz6  于 2022-11-09  发布在  其他
关注(0)|答案(2)|浏览(97)

我尝试使用JSONPath获取 * 池〉id〉选项〉id*

**基于此条件:**组件组〉id〉池Id =池〉id“池Id”:“产品编号:“一个或多个”,

我指的是下面有效载荷中的一个ID:

**示例1:**对于“池ID”:“cb 720883 - 04 f1 - 4 be 4-a416- 2f 0 c75230768”,池的标识应该是:

“身份证号”:“355548 B5-B 032 - 44 F5-BF 91-ACFE 987 BE 3AA”,
“编号”:“178709 F3-F47 D-4A 6 F-9AA 1-F27958 C628 EA”,
“产品编号”:“
“身份证号“:”

**示例2:**对于“池ID”:“fc2 ab 5c-c709 - 4 b1 d-81 a7-e61 a8 d120 d8 d”,池的标识符应该是:

“识别码”:“
“产品编号”:“B 0 F6 C744-AF 0A-4395-A2 D5-BFAF 39 AEEAB 5”,

我使用的JSON提取器:

请输入您的产品名称,然后输入您的产品名称,您就可以使用该产品了。

{
"error": null,
"data": [
    {
        "id": "d8af6a50-1bf4-4792-97ea-f9c819c60f8e",
        "productId": "1231a29f0c3-9180-4cd7-a5c7-282f6689c31a",
        "productName": "Acme One Hundred Percent",
        "pools": [
            {
                "id": "cb720883-04f1-4be4-a416-2f0c75230768",
                "options": [
                    {
                        "id": "355548b5-b032-44f5-bf91-acfe987be3aa",
                        "optionAmount": 1,
                        "optionIndex": 0,
                        "optionName": "$1",
                        "audio": null,
                        "image": "https://123./1-dollar-ball.png"
                    },
                    {
                        "id": "178709f3-f47d-4a6f-9aa1-f27958c628ea",
                        "optionAmount": 5,
                        "optionIndex": 1,
                        "optionName": "$5",
                        "audio": null,
                        "image": "https://123/5-dollar-ball.png"
                    },
                    {
                        "id": "b0a227b0-2bf8-47cc-8422-5114edfb5c41",
                        "optionAmount": 10,
                        "optionIndex": 2,
                        "optionName": "$10",
                        "audio": null,
                        "image": "https://123/10-dollar-ball.png"
                    },
                    {
                        "id": "ee8e2b49-7539-4ddd-90a4-6745b1385733",
                        "optionAmount": 20,
                        "optionIndex": 3,
                        "optionName": "$20",
                        "audio": null,
                        "image": "https://123/20-dollar-ball.png"
                    }
                ],
                "poolName": "Panel Amounts",
                "audio": null,
                "image": null
            },
            {
                "id": "2f1403cb-df3e-4fbf-b594-352f76943895",
                "options": [
                    {
                        "id": "a5dc21e7-cc4e-4e93-b74f-1f4b19f322ef",
                        "optionAmount": 0,
                        "optionIndex": 0,
                        "optionName": "Heads",
                        "audio": null,
                        "image": "https://123/OneHundredPercent/LibertyBellCoin.png"
                    }
                ],
                "poolName": "Heads",
                "audio": null,
                "image": null
            }
        ],
        "componentGroups": [
            {
                "id": "126140ac-1cfa-40a3-9ab7-1a84469ab0db",
                "poolId": "cb720883-04f1-4be4-a416-2f0c75230768",
                "components": [
                    {
                        "id": "8291365c-df9f-4d7b-8f34-be0b500065ee",
                        "componentConsumerSelectionType": 2,
                        "componentName": "Panel Amount",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Panel Amount Components",
                "audio": null,
                "image": null
            },
            {
                "id": "03ed0e60-8fba-4e01-83c2-ce960bf5e889",
                "poolId": "2f1403cb-df3e-4fbf-b594-352f76943895",
                "components": [
                    {
                        "id": "3f4b1a61-5d80-4b78-8c20-9f2b92022cf4",
                        "componentConsumerSelectionType": 1,
                        "componentName": "Heads",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Heads Components",
                "audio": null,
                "image": null
            }
        ]
    },
    {
        "id": "b203c9bc-1a7e-4fe5-9b5b-d8021ea118c6",
        "productId": "123557a97a5-ef93-46b7-868c-4f26439fbcb9",
        "productName": "Acme Pick 3",
        "pools": [
            {
                "id": "efc2ab5c-c709-4b1d-81a7-e61a8d120d8d",
                "options": [
                    {
                        "id": "cf85f8ca-7686-4585-b154-2e069e7bf976",
                        "optionAmount": 0.5,
                        "optionIndex": 0,
                        "optionName": "$.50",
                        "audio": null,
                        "image": "https://123/01.png"
                    },
                    {
                        "id": "b0f6c744-af0a-4395-a2d5-bfaf39aeeab5",
                        "optionAmount": 1,
                        "optionIndex": 1,
                        "optionName": "$1",
                        "audio": null,
                        "image": "https://123/01.png"
                    }
                ],
                "poolName": "Panel Amounts",
                "audio": null,
                "image": null
            },
            {
                "id": "60b8910b-baa7-4776-bb7a-05f277887a11",
                "options": [
                    {
                        "id": "d51485a5-1cb4-4aca-8ad9-551ac0bddce3",
                        "optionAmount": 0,
                        "optionIndex": 0,
                        "optionName": "Exact Order",
                        "audio": null,
                        "image": "https://123/tilestraight.png"
                    },
                    {
                        "id": "4ed3eaa0-7b58-47db-8072-bbe78f0e40cf",
                        "optionAmount": 0,
                        "optionIndex": 1,
                        "optionName": "Any Order",
                        "audio": null,
                        "image": "https://123/tilebox.png"
                    },
                    {
                        "id": "46571384-8bea-404b-8aa1-c0965fa0bed1",
                        "optionAmount": 0,
                        "optionIndex": 2,
                        "optionName": "50/50",
                        "audio": null,
                        "image": "https://123/tilefiftyfifty.png"
                    },
                    {
                        "id": "325d52e8-ed3f-4a69-8f09-8e49a53608dd",
                        "optionAmount": 0,
                        "optionIndex": 3,
                        "optionName": "Front Pair",
                        "audio": null,
                        "image": "https://123/tilefrontpair.png"
                    },
                    {
                        "id": "5960a4af-0b74-4c2b-b8a4-2dc4033e96a2",
                        "optionAmount": 0,
                        "optionIndex": 4,
                        "optionName": "Split Pair",
                        "audio": null,
                        "image": "https://123/tilesplitpair.png"
                    },
                    {
                        "id": "c2a817ca-1bd8-4b5b-8f6f-e12f3286ea54",
                        "optionAmount": 0,
                        "optionIndex": 5,
                        "optionName": "Back Pair",
                        "audio": null,
                        "image": "https://123/tilebackpair.png"
                    }
                ],
                "poolName": "Play Types",
                "audio": null,
                "image": null
            },
            {
                "id": "53fb7c9a-17dd-4f95-94b0-0110433404a2",
                "options": [
                    {
                        "id": "fae5912c-9d4a-466b-b515-d60b3186c2e5",
                        "optionAmount": 0,
                        "optionIndex": 0,
                        "optionName": "0",
                        "audio": null,
                        "image": "https://123/tilegreen00.png"
                    },
                    {
                        "id": "42055e6a-f08a-48b4-a7c8-41b87f11ca51",
                        "optionAmount": 0,
                        "optionIndex": 1,
                        "optionName": "1",
                        "audio": null,
                        "image": "https://123/tilegreen01.png"
                    },
                    {
                        "id": "ea28a99c-6068-4d67-8e2d-c6857656b499",
                        "optionAmount": 0,
                        "optionIndex": 2,
                        "optionName": "2",
                        "audio": null,
                        "image": "https://123/tilegreen02.png"
                    },
                    {
                        "id": "bf5e29ea-a377-46ad-865d-e4585d652b13",
                        "optionAmount": 0,
                        "optionIndex": 3,
                        "optionName": "3",
                        "audio": null,
                        "image": "https://123/tilegreen03.png"
                    },
                    {
                        "id": "41c26a4b-ce86-4c28-ae5a-35c13a539fbc",
                        "optionAmount": 0,
                        "optionIndex": 4,
                        "optionName": "4",
                        "audio": null,
                        "image": "https://123/tilegreen04.png"
                    },
                    {
                        "id": "fcb34895-25b9-4e5e-8a00-652febfcd31e",
                        "optionAmount": 0,
                        "optionIndex": 5,
                        "optionName": "5",
                        "audio": null,
                        "image": "https://123/tilegreen05.png"
                    },
                    {
                        "id": "0f0cf6ef-a7b7-4d11-98c4-0ea2cfd32f39",
                        "optionAmount": 0,
                        "optionIndex": 6,
                        "optionName": "6",
                        "audio": null,
                        "image": "https://123/tilegreen06.png"
                    },
                    {
                        "id": "3db2fafd-698c-44bb-a4be-f9e43ee6248b",
                        "optionAmount": 0,
                        "optionIndex": 7,
                        "optionName": "7",
                        "audio": null,
                        "image": "https://123/tilegreen07.png"
                    },
                    {
                        "id": "25d17003-9db8-407b-b6e2-65c0c2f014a0",
                        "optionAmount": 0,
                        "optionIndex": 8,
                        "optionName": "8",
                        "audio": null,
                        "image": "https://123/tilegreen08.png"
                    },
                    {
                        "id": "37232037-ca87-4f2e-99a4-40cbfec2bf62",
                        "optionAmount": 0,
                        "optionIndex": 9,
                        "optionName": "9",
                        "audio": null,
                        "image": "https://123/tilegreen09.png"
                    }
                ],
                "poolName": "Numbers",
                "audio": null,
                "image": null
            }
        ],
        "componentGroups": [
            {
                "id": "85ee94f1-fbcf-4392-aa08-5320abc13dcc",
                "poolId": "efc2ab5c-c709-4b1d-81a7-e61a8d120d8d",
                "components": [
                    {
                        "id": "a3d14456-64cb-4cae-b749-133c4b6a476a",
                        "componentConsumerSelectionType": 2,
                        "componentName": "Panel Amount",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Panel Amount Components",
                "audio": null,
                "image": null
            },
            {
                "id": "2be68fe5-2872-4631-b994-bb8e691db233",
                "poolId": "60b8910b-baa7-4776-bb7a-05f277887a11",
                "components": [
                    {
                        "id": "d50aeef2-4821-4247-b712-585a2ba55f81",
                        "componentConsumerSelectionType": 2,
                        "componentName": "Play Type",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Play Type Components",
                "audio": null,
                "image": null
            },
            {
                "id": "9b3433e8-48f3-4b37-bccb-e0ed5c55ffe8",
                "poolId": "53fb7c9a-17dd-4f95-94b0-0110433404a2",
                "components": [
                    {
                        "id": "ed6a4930-2558-414d-b47f-a3f95e719f60",
                        "componentConsumerSelectionType": 0,
                        "componentName": "Front Number",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Front Number Components",
                "audio": null,
                "image": null
            },
            {
                "id": "6ca0c5d1-0939-4603-9c0f-d6be5171a068",
                "poolId": "53fb7c9a-17dd-4f95-94b0-0110433404a2",
                "components": [
                    {
                        "id": "e0957685-22d8-4827-a3db-a1e2e0b5b76b",
                        "componentConsumerSelectionType": 0,
                        "componentName": "Middle Number",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Middle Number Components",
                "audio": null,
                "image": null
            },
            {
                "id": "e2ed942b-98e2-4d91-a500-ab5884acf66f",
                "poolId": "53fb7c9a-17dd-4f95-94b0-0110433404a2",
                "components": [
                    {
                        "id": "98b3c77a-bb25-4a45-a2ca-c90a79c75ecb",
                        "componentConsumerSelectionType": 0,
                        "componentName": "Back Number",
                        "audio": null,
                        "image": null
                    }
                ],
                "componentGroupName": "Back Number Components",
                "audio": null,
                "image": null
            }
        ]
    }
]

}

mrzz3bfm

mrzz3bfm1#

很难遵循你想要的。这是我的尝试:
[][][][][*][*]
或者,进一步挖掘:
请输入您的产品名称和地址,然后单击"下一步"。
创建JSON路径可能需要两个步骤:两个变量、构建模块。
次要问题:
1.您使用“=”而不是“==",请参阅您的“@.组件组..池ID =.池. *.id”
1.小心你路;您在某个时间点位于componentGroups中,但希望位于池中

nhaq1z21

nhaq1z212#

我认为您需要使用2个JSON提取器:
1.获取所需项目的所有池ID:

$.data[?(@.productId=='1231a29f0c3-9180-4cd7-a5c7-282f6689c31a')].pools.*.id

它将为您提供一个随机池ID,作为${pool_id} JMeter变量

1.然后你将能够得到这样的id:

$.data.*.pools.*[?(@.id == '${pool_id}')].options.*.id

这样您将获得所有池ID:

您可以使用Debug Sampler和View Results Tree监听器组合来查看所有JMeter Variables及其各自的值。

相关问题