Extract child and nested child value in the result.

75 views
Skip to first unread message

Krishna Gandra

unread,
Feb 10, 2016, 7:15:27 PM2/10/16
to JsonPath
I am trying to access both child attribute and nested child, please let me know if you have a solution.

Given the following JSON doc:

[
  {
    "ID": "1",
    "Name": "Sam",
    "Info": {
      "Salary": "100",
      "FullTime": "Yes"
    }
  },
  {
    "ID": "2",
    "Name": "Ben",
    "Info": {
      "Salary": "200",
      "FullTime": "Yes"
    }
  }
]

I want to convert into

[
{"ID":"1", "Name":"Sam", "Salary":"100"},
{"ID":"2", "Name":"Ben", "Salary":"200"}
]

I tried:

$.[*]['ID','Name','Info.Salary'] 

but it gives only ID and Name.

Thanks
-Krishna

kalle stenflo

unread,
Feb 11, 2016, 3:10:39 AM2/11/16
to JsonPath
Sorry, That can't be done.

--
You received this message because you are subscribed to the Google Groups "JsonPath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonpath+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Krishna Gandra

unread,
Feb 11, 2016, 12:13:14 PM2/11/16
to JsonPath
Thank you for the response, can you please suggest if there is any better way to achieve this using jsonpath functionality in java code?  otherwise I am thinking first flatten input json and apply jsonpath on top of it.
Reply all
Reply to author
Forward
0 new messages