How to find parent Json node while parsing a JSON

Viewed 16515

I am parsing a JSON Stream using Jackson.

API that I am using is ObjectMapper.readTree(..)

Consider following stream:

{
  "type": "array",
  "items": {
      "id": "http://example.com/item-schema",
      "type": "object",
      "additionalProperties": {"$ref": "#"}
  }
}

Now when I read additionalProperties, I figure out there is a "$ref" defined here. Now to resolve the reference, I need to go to its parent and figure out the id (to resolve the base schema).

I can't find any API to go to parent of JsonNode holding additionalProperties. Is there a way I can achieve this?

Info:

Why I need this is I need to find the base schema against which $ref has to be resolved. And to figure out base schema, I need to know the id of its parents..

3 Answers
Related