0

I want to find the jsonpath expression for extracting value in arrays, without flattening. For example, here's the json

[
    {
        "id": "1",
        "label": [
            {
                "id": "1.1",
                "tag": "tag1.1"
            },
            {
                "id": "1.2",
                "tag": "tag1.2"
            }
        ]
    },
        {
        "id": "2",
        "label": [
            {
                "id": "2.1",
                "tag": "tag2.1"
            }
        ]
    },
    {
        "id": "3",
        "label": []
    }
]

Here's the desired output

[
    ['tag1.1','tag1.2'],
    ['tag2.1'],
    []
]

Here's my best solution so far

$.*[label]

and the not-so-perfect result

[
  [
    {
      "id": "1.1",
      "tag": "tag1.1"
    },
    {
      "id": "1.2",
      "tag": "tag1.2"
    }
  ],
  [
    {
      "id": "2.1",
      "tag": "tag2.1"
    }
  ],
  []
]

thanks a lot in advance

Kleenex
  • 75
  • 1
  • 2
  • 7

0 Answers0