How to get JSON Object from JSONNode Array?

362 views Asked by At

I have a JsonNode which looks like:

[
  {
    "ObjectIWantToRetrieve": {
      "key0": {
        "key1": {
          "key2": "val3"
          ]
        }
      }
    }
  }
]

I wish to get the ObjectIWantToRetrieve out The equivalent of JsonNode.get("ObjectIWantToRetrieve"). Can anyone help me? Should I be converting the JSONNode to ArrayNode Please advice thank you

1

There are 1 answers

0
Jordy On BEST ANSWER

You should convert it to ObjectNode first like this :

ObjectNode value = ((ObjectNode) JsonNode.get(0)).get("ObjectIWantToRetrieve")