'How to retrieve an object name in JSON with jsonpath?

Using jsonpath with a JSON input in Pentaho Data Integration/Kettle I am trying and failing to retrieve the objects names:

{
  "otherobject":"dontcare",
  "objectid_01":{
    "property_01":"a",
    "property_02":["s","t"]
  },
  "objectid_02":{
    "property_01":"b",
    "property_02":["u","v"]
  }
}

I am able to extract ["a","b"] with $..property_01 but I would also need to get the names/ids/keys/whatever they are called ["objectid_01","objectid_02"] with jsonpath.

Greatly appreciate your help in advance!



Solution 1:[1]

you can try:

$.objectid_01.property_01
$.objectid_01.property_02

or

$.objectid_01.*.property_02

This syntax works in json input!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander van Oostenrijk