title: Identity info missing when serializing ids with the Jackson JSON parser
body: <p>I am currently trying to serialize an object tree and deserialize it afterwards, so that all references remain the same. The problem is, that the fields holding those references are of type Object. The following code snippet</p>
  
  <pre><code>public class Main {
  
      public static void main(String[] args) throws IOException {
          Root r = new Root();
          Element e = new Element();
          e.s = "test";
          r.o1 = e;
          r.o2 = e;
  
          ObjectMapper ma = new ObjectMapper();
          ma.addMixInAnnotations(Object.class, Mixin.class);
  
          String json = ma.writeValueAsString(r);
          System.out.println(json);
  
          Root r2 = ma.readValue(json, Root.class);
          System.out.println(r2.o1.getClass());
          System.out.println(r2.o2.getClass());
          System.out.println(r2.o1 == r2.o2);
      }
  
  
  
      public static class Root {
  
          public Object o1;
  
          public Object o2;
  
      }
  
      public static class Element {
  
          public String s;
  
      }
  
      @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
      @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id")
      public static class Mixin {
  
      }
  
  }
  </code></pre>
  
  <p>results in the following output:</p>
  
  <pre><code>{"@class":"Main$Root","@id":1,"o1":{"@class":"Main$Element","@id":2,"s":"test"},"o2":2}
  Main$Element
  java.lang.Integer
  false
  </code></pre>
  
  <p>The first occurence of 'Element' is deserialized correctly, as it has the type information attached to it. The second one however is not, as the type information is not added when only the id is serialized. The id is deserialized as an Integer, because the parser does not recognize it as an id, because the field is of type 'Object'.</p>
  
  <p>So the question is: Is there a way to tell Jackson to attach type information even when writing only the id, so that the deserialized 'Elements' are the same?</p>
  
  <p>EDIT: The type must be Object, since in my use case the content can be practically anything, even classes I have no control of. So the main issue is how to inculde the type information in the reference itself.</p>
  
  <p>Thank you for your time.</p>