Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jsonpath for nested JSON objects

Tags:

json

jsonpath

I have a JSON with nested fields:

  [
    {
    "Platform Parent Dato Id": "23768",
    "Platform Dato Id": "24138",
    "Platform Dato Name": "Random Europe",
    "Platform mission Id": "111112",
    "Platform submission Id": "638687",
    "Platform submission Flight Id": "863524",
    "Start Date": "2017-12-01",
    "End Date": "2017-12-02",
    "Platform Compensation": 109.0909,
    "Total Value": 909.0909,
    "Goal": "200000.0000",
    "Value Information": {
      "Platform Compensation": [
        {
          "Platform mission Id": "111112",
          "Platform submission Id": "638687",
          "Platform submission Flight Id": "863524",
          "Value Rate": "14.0000",
          "Value": 109.0909
        }
      ]
    }
  },
  {
    "Platform Parent Dato Id": "23768",
    "Platform Dato Id": "24138",
    "Platform Dato Name": "Random Europe",
    "Platform mission Id": "111113",
    "Platform submission Id": "638687",
    "Platform submission Flight Id": "863524",
    "Start Date": "2017-12-01",
    "End Date": "2017-12-02",
    "Platform Compensation": 109.0909,
    "Total Value": 909.0909,
    "Goal": "200000.0000",
    "Value Information": {
      "Platform Compensation": [
        {
          "Platform mission Id": "111113",
          "Platform submission Id": "638687",
          "Platform submission Flight Id": "863524",
          "Value Rate": "12.0000",
          "Value": 109.0909
        }
      ]
    }
  }
  ]

and I am using a JSONPATH in order to get the Value Rate from the Value Information nest.

I have pasted my JSON text in this website: http://jsonpath.com/ and after using this line:

$[*].['Platform Compensation'].['Value Rate']

I am getting this:

enter image description here

and after using this line:

$.['Value Information'].['Platform Compensation'].['Platform mission Id']

I am getting this:

enter image description here

What I am trying to return (output) is the following:

enter image description here

but I cannot find the right syntax to combine those two in one line and return both with one JSONPATH query.

like image 563
Datacrawler Avatar asked Dec 04 '17 12:12

Datacrawler


1 Answers

Jayway implementation let you do that. The jsonpath would be $.[*]['Value Information']['Platform Compensation'][*]['Platform mission Id', 'Value Rate']

You can try it in this website http://jsonpath.herokuapp.com/

like image 127
Pompelmo Avatar answered Oct 20 '22 05:10

Pompelmo