title: Json Deserializer - How to get data from parent JSON object
body: <p>I am using Spring MVC and spring take care of converting json to Objects in controller. But my json structure is different then class structure. So I have written my own deserializer. But I am getting problem to accessing values of parent object in JSON. I think it is better to explain my problem using some example - </p>
  
  <p>I have following JSON to deserialize</p>
  
  <pre><code>{
    id: 1,
    children: {
      "name1": "value1",
      "name2": "value2"
    }
  }
  </code></pre>
  
  <p>I have following classes (Sample Code) - </p>
  
  <pre><code>public class Parent {
      private Integer id;
  
      @JsonDeserialize(using= ChildrenDeserializer.class)
      private List&lt;Child&gt; children;
      //... Getter/setters
  }
  
  public class Child {
      private Integer id;
      private String name;
      private String value;
  
      //...getters/setters
  }
  
  public class ChildrenDeserializer extends JsonDeserializer&lt;List&lt;Child&gt;&gt; {
      @Override
      public List&lt;Child&gt; deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
          List&lt;Child&gt; children = new ArrayList&lt;&gt;();
  
          ObjectCodec oc = jsonParser.getCodec();
          JsonNode node = oc.readTree(jsonParser);
          Iterator&lt;Map.Entry&lt;String, JsonNode&gt;&gt; fieldsIterator = node.fields();
  
          while (fieldsIterator.hasNext()) {
              Map.Entry&lt;String, JsonNode&gt; field = fieldsIterator.next();
              String name = field.getKey();
              String value = field.getValue().textValue();
  
              Child child = new Child();
  
              //Here I want to get parentId from the Json. Is it possible??
              Integer childId = childRepository.searchChildIdByParentId(parentId, name);
  
              child.setId(childId);
              child.setName(name);
              child.setValue(value);
              children.add(child);
          }
  
          return children;
      }
  }
  </code></pre>
  
  <p>Is there any way to get parentId (which is 1 in above example) while deserializing children??</p>