title: Jackson Custom Deserialize
body: <p>I would like deserialize my custom serialized objects. My objects are basically consisting a simple Pair implementation. </p>
  
  <pre><code>class School{
    Integer id;
    String schoolName;
  }
  
  class Student{
    Integer id;
    Integer schoolId;
    String studentName;
  }
  
  @JsonSerialize(using=PairSerializer.class)
  public class Pair&lt;V,K&gt;{
     V v;
     K k;
  }
  </code></pre>
  
  <p>Here is the result</p>
  
  <pre><code> [
     {
        "v":{
           "id":1,
           "schoolId":3,
           "studentName":"O. Bas"
        },
        "k":{
           "id":3,
           "schoolName":"School 3"
        }
     },
     {
        "v":{
           "id":2,
           "schoolId":3,
           "studentName":"C. Koc"
        },
        "k":{
           "id":3,
           "schoolName":"School 3"
        }
     }
  ]
  </code></pre>
  
  <p>v and k as field name in json is pretty ugly. That is why I have written a custom serializer as this:</p>
  
  <pre><code>@Override
  public void serialize(Pair pair, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
    jsonGenerator.writeStartObject();
    jsonGenerator.writeObjectField(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,pair.getK().getClass().getSimpleName() ), pair.getK());
    jsonGenerator.writeObjectField(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL,pair.getV().getClass().getSimpleName() ), pair.getV());
    jsonGenerator.writeEndObject();
  }
  </code></pre>
  
  <p>The result is exactly what I want. v and k field names are replaced by their class names.</p>
  
  <pre><code>[
     {
        "school":{
           "id":3,
           "schoolName":"School 3"
        },
        "student":{
           "id":1,
           "schoolId":3,
           "studentName":"O. Bas"
        }
     },
     {
        "school":{
           "id":3,
           "schoolName":"School 3"
        },
        "student":{
           "id":2,
           "schoolId":3,
           "studentName":"C. Koc"
        }
     }
  ]
  </code></pre>
  
  <p>Here is the my question. How can I deserialize my json string to <code>List&lt;Pair&lt;V, K&gt;</code> ? The real problem is that V and K are depends on the deserialized context it might vary as Student, School or another pair implementation. </p>
  
  <pre><code>public class PairDeserializer extends JsonDeserializer&lt;Pair&gt; {
  
     public PairDeserializer() {
     }
  
     @Override
     public Pair deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
           // I need to Deserialized generic type information of Pair
  
     }
  }
  </code></pre>