title: How to deserialize one JSON object for multiple classes using Java
body: <p>I am new to JSON deserialization stuffs. I have multiple classes that use the same JSON string.</p>
  
  <p>The JSON looks like this:</p>
  
  <pre><code>"part1": {
      "part2": {
        "part3": {
          "value": [Some Integers]
        }
      }
  }
  </code></pre>
  
  <p>Below is my code for deserialization:</p>
  
  <pre><code>public class ConfirmationDeserializer extends JsonDeserializer&lt;Confirmation_A&gt;
  {
      @Override
      public Confirmation deserialize(JsonParser parser, DeserializationContext context)
              throws IOException, JsonProcessingException
      {
          JsonNode node = parser.getCodec().readTree(parser);
          JsonNode Part3_Node = node.get("part2").get("part3");
          Integer value = Part3_Node.get("value").intValue();
          int some_class = new Some_class(value);
  
          #Return response class
          return new Confirmation_A(some_class);
      }
  }
  </code></pre>
  
  <p>The problem is that I have Confirmation_A, Confirmation_B, and Confirmation_C (they all extend the same abstract parent class), and they are all using the same JSON string and have the same parameter (some_class). It will be redundant if I create three deserializers that actually use the exactly same code and just return different response class. Is it possible to just create one deserializer for all of these three classes? Thanks in advance. </p>