Search code examples
json-path-expression

I want to extract only a specific value using jsonpath


How to use jsonpath to extract only id value from Json like below?

[
      {
      "Name": "Test",
      "Code": "00",
      "options": [      {
         "id": "SS111",
         "roundTrip": false,
         "price": 53900,
         "trains": [         {
            "packageDiscount": 3244,
            "goodsType": "REGULAR"
         }],
         "adults": 1
      }],
      "type": "DOMESTIC_TRAIN"
   },
   {
      "Name": "Test",
      "Code": "00",
      "options": [      {
         "id": "SS222",
         "roundTrip": false,
         "price": 53900,
         "trains": [         {
            "packageDiscount": 3244,
            "goodsType": "REGULAR"
         }],
         "adults": 1
      }],
      "type": "DOMESTIC_TRAIN"
   }
]

The result I want is as below.

SS111,
SS222

Please tell me about Jsonpath.Please tell me about Jsonpath.Please tell me about Jsonpath.Please tell me about Jsonpath.Please tell me about Jsonpath.


Solution

  • Use .. - Deep Scan operator

    $..id
    

    Online Test Tool : https://jsonpath.herokuapp.com/