1

{"data": {"callOrders": [{ "promotionId": null, "Promotion": null, "Lines": [ { "id": 5105808, "quantity": 10, "skuId": 769, "callId": 494285, "skuBatchId": 733, "amountDetails": { "rate": 197.53, "grossAmount": 2232.089, "netAmount": 2232.089, "taxAmount": 256.789, "taxableAmount": 1975.3, "subTotal": 1975.3, "billDiscount": 0, "tradeDiscount": 0, "discountAmount": 0, "promotionDiscount": 0, "topUpDiscount": 0, "__typename": "AmountDetail" }, "rateDetails": { "rlp": 197.53, "rlpWithVat": 223.2089, "netPrice": 197.53, "netPriceWithVat": 223.2089, "__typename": "RateDetail" }, "SKU": { "id": 769, "title": "H&S 2in1 Active Protect 180 ml x 24 [82302894]", "__typename": "SKU" }, "SKUBatch": { "priceDetails": { "rlp": 197.53, "dlp": 186.35, "vatPercentage": 0.13, "mrpSrp": 250, "mrpStatus": true, "__typename": "SKUPrice" }, "batchDetails": { "batchNumber": "DEFAULT_BATCH", "__typename": "SKUBatch" }, "usageDate": { "manufacture": "0000-00-00", "expiry": "0000-00-00", "__typename": "SKUUsage" }, "updatedAt": "2019-11-05", "active": true, "__typename": "SKUBatchRate" }, "Promotion": { "id": null, "title": null, "type": null, "scope": null, "criteria": null, "__typename": "Promotion" }, "promotionId": null, "distributorId": 16, "__typename": "Line", "inStock": "INSTOCK", "freeSku": false, "focusedSku": false }, { "id": 5105809, "quantity": 50, "skuId": 95, "callId": 494285, "skuBatchId": 111, "amountDetails": { "rate": 56.89, "grossAmount": 3214.2852, "netAmount": 3214.285, "taxAmount": 369.785, "taxableAmount": 2844.5, "subTotal": 2844.5, "billDiscount": 0, "tradeDiscount": 0, "discountAmount": 0, "promotionDiscount": 0, "topUpDiscount": 0, "__typename": "AmountDetail" }, "rateDetails": { "rlp": 56.89, "rlpWithVat": 64.2857, "netPrice": 56.89, "netPriceWithVat": 64.2857, "__typename": "RateDetail" }, "SKU": { "id": 95, "title": "Whisper Choice 6s x 96 [82252488]", "__typename": "SKU" }, "SKUBatch": { "priceDetails": { "rlp": 56.89, "dlp": 53.67, "vatPercentage": 0.13, "mrpSrp": 72, "mrpStatus": true, "__typename": "SKUPrice" }, "batchDetails": { "batchNumber": "DEFAULT_BATCH", "__typename": "SKUBatch" }, "usageDate": { "manufacture": "0000-00-00", "expiry": "0000-00-00", "__typename": "SKUUsage" }, "updatedAt": "2016-08-15", "active": true, "__typename": "SKUBatchRate" }, "Promotion": { "id": null, "title": null, "type": null, "scope": null, "criteria": null, "__typename": "Promotion" }, "promotionId": null, "distributorId": 16, "__typename": "Line", "inStock": "INSTOCK", "freeSku": false, "focusedSku": false }, { "id": 5105810, "quantity": 10, "skuId": 82, "callId": 494285, "skuBatchId": 551, "amountDetails": { "rate": 281.88, "grossAmount": 3185.244, "netAmount": 3185.244, "taxAmount": 366.444, "taxableAmount": 2818.8, "subTotal": 2818.8, "billDiscount": 0, "tradeDiscount": 0, "discountAmount": 0, "promotionDiscount": 0, "topUpDiscount": 0, "__typename": "AmountDetail" }, "rateDetails": { "rlp": 281.88, "rlpWithVat": 318.5244, "netPrice": 281.88, "netPriceWithVat": 318.5244, "__typename": "RateDetail" }, "SKU": { "id": 82, "title": "Ariel Oxyblu 1 kg x 24 [82250306]", "__typename": "SKU" }, "SKUBatch": { "priceDetails": { "rlp": 281.88, "dlp": 268.45, "vatPercentage": 0.13, "mrpSrp": 344, "mrpStatus": true, "__typename": "SKUPrice" }, "batchDetails": { "batchNumber": "DEFAULT_BATCH", "__typename": "SKUBatch" }, "usageDate": { "manufacture": "0000-00-00", "expiry": "0000-00-00", "__typename": "SKUUsage" }, "updatedAt": "2018-01-31", "active": true, "__typename": "SKUBatchRate" }, "Promotion": { "id": null, "title": null, "type": null, "scope": null, "criteria": null, "__typename": "Promotion" }, "promotionId": null, "distributorId": 16, "__typename": "Line", "inStock": "INSTOCK", "freeSku": false, "focusedSku": false } ], "__typename": "PromotionOrder" }]}}

Using $..Lines..id I am getting this [ 5105808, 769, null, 5105809, 95, null, 5105810, 82, null ]

But I want to get value [ 5105808, 5105809, 5105810] only. What should be the way to achieve it?

0

2 Answers 2

2

This is a possible solution:

$..[?(@.skuId)].id

This gets elements that have the skuId attribute and extracts the id attribute.

Sign up to request clarification or add additional context in comments.

1 Comment

I want to learn more to get data from json. Where can I learn or find more json path expressions? Thanks
0

You're using .. which is a deep scan operator which means that you're looking for all id attribute values no matter where they're located in the JSON.

If you want to get only id of the attributes which are direct children of the Lines object - you need to amend your query to look like: $..Lines[*].id

Demo:

enter image description here

More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.