JsonPath - how to read attributes from different level

Viewed 543

I try to use JsonPath to extract values from attributes at different levels of my json object.

Here's my object:

{
    "A": [
        {
            "B": "0",
            "C": "1",
            "D": {
                "E" : "2",
                "F" : "3",
            }
        },
        {
            "B": "4",
            "C": "5",
            "D": {
                "E" : "6",
                "F" : "7",
            }
        }
    ]
}

And I would like to extract in the same time the B and the E values

to get the B, easy : $.A[*].B

to get the E, easy : $.A[*].D.E

to get B and C, easy using the Bracket-notated children operator : $.A[*]['B', 'C']

But to get B and E in the same time, I don't get the correct expression. I expect to have :

[ 
  { "B":"0", "E" : "2"}, 
  { "B":"4", "E" : "7"} 
]

Does someone have the correct expression?

Thanks

E.

0 Answers
Related