JSON路径| JMeter |条件提取

5lhxktic  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(150)

我尝试使用JSONPath获取〉“id”的通道:“6af 38171 - 867 c-414 f-a128 - 6668 fc 66 cd 20”,基于不同请求提供的产品ID
示例1:对于“productId”:“3211 a29 f0 c3 -9180- 4cd 7-a5 c7 - 282 f6689 c31 a”,通道标识应为“标识”:“29 b13081 - 760 a-4451- 81 d8 - 25 f0944 b3658”,已在美国注册,
示例2:对于“productId”:“321557 a97 a5-ef 93 - 46 b7 - 868 c-4f 26439 fbcb 9”,通道标识应为“标识”:“第一次使用”,
示例3:对于“productId”:“321 ecc 29 f29-bc 03 - 41 d 7-b107-db 3be 8103216”,通道标识应该是“标识”:“293 e31 b4 - 8 ebb-40 af-8015- 44 b1 a37 ba 84 f”,这是一个很好的例子。
从上一个请求中随机选取的productId
该产品的名称为“产品名称”,名称为“产品名称”。

有效负载

{
    "error": null,
    "data": [
        {
            "id": "c0c18687-26cc-48da-b60a-d386279d1c3e",
            "channels": [
                {
                    "id": "29b13081-760a-4451-81d8-25f0944b3658",
                    "promotionRule": {
                        "id": "18f84232-7350-4f9f-8037-7e92eebbc4d4",
                        "promotionProducts": [
                            {
                                "id": "2d755bfe-8b8f-4b2a-9bf4-e8e626975b51",
                                "productId": "3211a29f0c3-9180-4cd7-a5c7-282f6689c31a",
                                "instanceCountMin": 0,
                                "instanceCountMax": 0,
                                "promotionProductRules": [
                                    {
                                        "componentConstraints": [
                                            {
                                                "description": "Panel Amount",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 2,
                                                "componentId": "8291365c-df9f-4d7b-8f34-be0b500065ee",
                                                "options": null
                                            }
                                        ],
                                        "canBeCombined": false,
                                        "priority": 0,
                                        "promotionRecurrence": null,
                                        "extensions": {},
                                        "externalId": null,
                                        "sponsorshipAppliesToEntities": [],
                                        "createdOn": "2022-03-25T18:37:15.5161071+00:00",
                                        "updatedOn": null,
                                        "deletedOn": null,
                                        "releaseOn": null,
                                        "expireOn": null,
                                        "expiredOn": null,
                                        "currency": "USD",
                                        "ruleDescription": null,
                                        "ruleName": null,
                                        "simulationTypes": 0,
                                        "value": 0.0
                                    }
                                ]
                            }
                        ],
                        "maxDistributionCount": null,
                        "selectablePromotionsMin": 1,
                        "selectablePromotionsMax": 1,
                        "canBeCombined": false,
                        "priority": 0,
                        "promotionRecurrence": null,
                        "extensions": {},
                        "externalId": null,
                        "sponsorshipAppliesToEntities": [],
                        "createdOn": "2022-03-25T18:37:15.5152919+00:00",
                        "updatedOn": null,
                        "deletedOn": null,
                        "releaseOn": "2022-03-25T18:37:15.5168274+00:00",
                        "expireOn": null,
                        "expiredOn": null,
                        "currency": "USD",
                        "ruleDescription": null,
                        "ruleName": null,
                        "simulationTypes": 0,
                        "value": 0.0
                    },
                    "authorityName": null,
                    "currency": "USD",
                    "channelName": "The Islands of The Bahamas",
                    "channelLogo": "https://123/cdn/BahamasTourismBoard.png",
                    "channelLogoHD": null,
                    "channelAnimated": null,
                    "channelAnimatedHD": null,
                    "sortOrder": 0,
                    "releaseOn": null,
                    "expireOn": null,
                    "expiredOn": null,
                    "suspendedOn": null,
                    "suspendedBy": null
                }
            ],
            "priority": 0,
            "brandName": null,
            "channelGroupName": "100%",
            "channelGroupLogo": "https://123/media/100percentlogo.png",
            "channelGroupLogoHD": "https://123/media/100percentlogo.png",
            "channelGroupAnimated": null,
            "channelGroupAnimatedHD": null,
            "releaseOn": null,
            "expireOn": null,
            "expiredOn": null,
            "suspendedOn": null,
            "suspendedBy": null
        },
        {
            "id": "e2de2a1f-a21b-41db-82c0-a5710cf59dee",
            "channels": [
                {
                    "id": "6af38171-867c-414f-a128-6668fc66cd20",
                    "promotionRule": {
                        "id": "074eced6-9894-4313-85e2-2a04965fc8eb",
                        "promotionProducts": [
                            {
                                "id": "b93ccce2-171b-4e4e-83d7-fd77632acb4f",
                                "productId": "321557a97a5-ef93-46b7-868c-4f26439fbcb9",
                                "instanceCountMin": 0,
                                "instanceCountMax": 0,
                                "promotionProductRules": [
                                    {
                                        "componentConstraints": [
                                            {
                                                "description": "Panel Amount",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 2,
                                                "componentId": "a3d14456-64cb-4cae-b749-133c4b6a476a",
                                                "options": null
                                            },
                                            {
                                                "description": "Play Type",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 2,
                                                "componentId": "d50aeef2-4821-4247-b712-585a2ba55f81",
                                                "options": null
                                            },
                                            {
                                                "description": "Front Number",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "ed6a4930-2558-414d-b47f-a3f95e719f60",
                                                "options": null
                                            },
                                            {
                                                "description": "Middle Number",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "e0957685-22d8-4827-a3db-a1e2e0b5b76b",
                                                "options": null
                                            },
                                            {
                                                "description": "Back Number",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "98b3c77a-bb25-4a45-a2ca-c90a79c75ecb",
                                                "options": null
                                            }
                                        ],
                                        "canBeCombined": false,
                                        "priority": 0,
                                        "promotionRecurrence": null,
                                        "extensions": {},
                                        "externalId": null,
                                        "sponsorshipAppliesToEntities": [],
                                        "createdOn": "2022-03-25T20:17:01.7837463+00:00",
                                        "updatedOn": null,
                                        "deletedOn": null,
                                        "releaseOn": null,
                                        "expireOn": null,
                                        "expiredOn": null,
                                        "currency": "USD",
                                        "ruleDescription": null,
                                        "ruleName": null,
                                        "simulationTypes": 0,
                                        "value": 0.0
                                    }
                                ]
                            }
                        ],
                        "maxDistributionCount": null,
                        "selectablePromotionsMin": 1,
                        "selectablePromotionsMax": 1,
                        "canBeCombined": false,
                        "priority": 0,
                        "promotionRecurrence": null,
                        "extensions": {},
                        "externalId": null,
                        "sponsorshipAppliesToEntities": [],
                        "createdOn": "2022-03-25T20:17:01.7829809+00:00",
                        "updatedOn": null,
                        "deletedOn": null,
                        "releaseOn": "2022-03-25T20:17:01.7844511+00:00",
                        "expireOn": null,
                        "expiredOn": null,
                        "currency": "USD",
                        "ruleDescription": null,
                        "ruleName": null,
                        "simulationTypes": 0,
                        "value": 0.0
                    },
                    "authorityName": null,
                    "currency": "USD",
                    "channelName": "The Islands of The Bahamas",
                    "channelLogo": "https://123/cdn/BahamasTourismBoard.png",
                    "channelLogoHD": "https://123/cdn/BahamasTourismBoard.png",
                    "channelAnimated": null,
                    "channelAnimatedHD": null,
                    "sortOrder": 0,
                    "releaseOn": null,
                    "expireOn": null,
                    "expiredOn": null,
                    "suspendedOn": null,
                    "suspendedBy": null
                }
            ],
            "priority": 0,
            "brandName": null,
            "channelGroupName": "Pick 3",
            "channelGroupLogo": "https://123/brandmedia/AcmePick3.png",
            "channelGroupLogoHD": "https://123/brandmedia/AcmePick3.png",
            "channelGroupAnimated": null,
            "channelGroupAnimatedHD": null,
            "releaseOn": null,
            "expireOn": null,
            "expiredOn": null,
            "suspendedOn": null,
            "suspendedBy": null
        },
        {
            "id": "b234c6b1-ffba-4883-ae9a-d6483b4787ab",
            "channels": [
                {
                    "id": "293e31b4-8ebb-40af-8015-44b1a37ba84f",
                    "promotionRule": {
                        "id": "863b5465-d5ab-4433-bea2-2b0d4da0cfcc",
                        "promotionProducts": [
                            {
                                "id": "c5031107-3995-48d0-8f26-95597531e7e4",
                                "productId": "321ecc29f29-bc03-41d7-b107-db3be8103216",
                                "instanceCountMin": 0,
                                "instanceCountMax": 0,
                                "promotionProductRules": [
                                    {
                                        "componentConstraints": [
                                            {
                                                "description": "Panel Amount",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 2,
                                                "componentId": "db7ae266-bf79-4d63-984a-aea1aa7af460",
                                                "options": null
                                            },
                                            {
                                                "description": "White Ball - 1",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "8b750179-6ead-425e-b5a2-ab422e72a03e",
                                                "options": null
                                            },
                                            {
                                                "description": "White Ball - 2",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "3a87a9aa-d8c8-465a-ae35-f7d894204b13",
                                                "options": null
                                            },
                                            {
                                                "description": "White Ball - 3",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "6b674bc4-1143-4558-8020-88872064b6d2",
                                                "options": null
                                            },
                                            {
                                                "description": "White Ball - 4",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "0cf02fdf-c717-4ea0-a230-cb837792e7f5",
                                                "options": null
                                            },
                                            {
                                                "description": "White Ball - 5",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "e627485b-eb3b-4afe-a20d-bed5c30ba195",
                                                "options": null
                                            },
                                            {
                                                "description": "Powerball",
                                                "extensions": null,
                                                "amountOfAdjustment": 0.0,
                                                "componentConsumerSelectionType": 1,
                                                "componentId": "e4c6e609-954a-4707-88b5-c47993fb3f82",
                                                "options": null
                                            }
                                        ],
                                        "canBeCombined": false,
                                        "priority": 0,
                                        "promotionRecurrence": null,
                                        "extensions": {},
                                        "externalId": null,
                                        "sponsorshipAppliesToEntities": [],
                                        "createdOn": "2022-03-25T18:44:42.9594038+00:00",
                                        "updatedOn": null,
                                        "deletedOn": null,
                                        "releaseOn": null,
                                        "expireOn": null,
                                        "expiredOn": null,
                                        "currency": "USD",
                                        "ruleDescription": null,
                                        "ruleName": null,
                                        "simulationTypes": 0,
                                        "value": 0.0
                                    }
                                ]
                            }
                        ],
                        "maxDistributionCount": null,
                        "selectablePromotionsMin": 1,
                        "selectablePromotionsMax": 1,
                        "canBeCombined": false,
                        "priority": 0,
                        "promotionRecurrence": null,
                        "extensions": {},
                        "externalId": null,
                        "sponsorshipAppliesToEntities": [],
                        "createdOn": "2022-03-25T18:44:42.9586017+00:00",
                        "updatedOn": null,
                        "deletedOn": null,
                        "releaseOn": "2022-03-25T18:44:42.9601687+00:00",
                        "expireOn": null,
                        "expiredOn": null,
                        "currency": "USD",
                        "ruleDescription": null,
                        "ruleName": null,
                        "simulationTypes": 0,
                        "value": 0.0
                    },
                    "authorityName": null,
                    "currency": "USD",
                    "channelName": "The Islands of The Bahamas",
                    "channelLogo": "https://123/cdn/BahamasTourismBoard.png",
                    "channelLogoHD": "https://123/cdn/BahamasTourismBoard.png",
                    "channelAnimated": null,
                    "channelAnimatedHD": null,
                    "sortOrder": 0,
                    "releaseOn": null,
                    "expireOn": null,
                    "expiredOn": null,
                    "suspendedOn": null,
                    "suspendedBy": null
                }
            ],
            "priority": 0,
            "brandName": null,
            "channelGroupName": "Powerball",
            "channelGroupLogo": "https://123/brandmedia/PowerballLogo.png",
            "channelGroupLogoHD": "https://123/brandmedia/PowerballLogo.png",
            "channelGroupAnimated": null,
            "channelGroupAnimatedHD": null,
            "releaseOn": null,
            "expireOn": null,
            "expiredOn": null,
            "suspendedOn": null,
            "suspendedBy": null
        }
    ]
}
xqk2d5yq

xqk2d5yq1#

“Your”$..[?(@.promotionRule.promotionProducts[0].productId=="ecc29f29-bc03-41d7-b107-db3be8103216" )].id表达式对我来说很好用(假设我将321添加到开头以匹配响应数据

如果它不适合您-请使用Debug Sampler and View Results Tree listener combination检查${je_productId}JMeter Variable
还要注意,JMeter变量不会在View Results Tree监听器的“JSON Path Tester”模式中进行求值,主要是因为它们不存在于该模式中。

相关问题