8

I have data like so:

{"key": {"name":"hi", "size":10}}

"key" is a dynamic value. It isn't fixed. I can access name and size using this JSON Path:

*.name
*.size

How can I get the value of "key" itself with JSON Path? * gives me the entire row of data, and both $ and @ give me "no element found" in my parser.

I'm trying to do this in Pentaho with a JSON Input step.

gdm
  • 905
  • 1
  • 15
  • 21

3 Answers3

4

$.* will give you all elements of parent object, in your example you will get something like

[
   {
      "name":"hi",
      "size":10
   }
]

according to: http://jsonpath.curiousconcept.com/

zpon
  • 1,482
  • 1
  • 15
  • 21
1

This is not possible to do with the Pentaho JSON Input step, as this uses JSONPath as you say. You need to do it another way. For example with the Modified Java Script Value:

var obj = JSON.parse(json);
var keys = Object.keys(obj);
bolav
  • 6,938
  • 2
  • 18
  • 42
0

I had the same issue as one way of interpreting your question: If you actually want to get the output ["key"] from your example without having to specify "key" in your input. then don't use jsonPath(data,...somequery...) at all. Simply use Object.keys(data). I am working in Javascript, and am not familiar with Pentaho, so i don't know if my answer applies to your situation.