title: Why doesn't Jackson use serialize() Method of custom wrapper class extending LinkedHashMap
body: <p>I am using Jackson 2.3.2 library in a Spring MVC project and trying to specify a custom JSON serialization on a custom wrapper Object by implementing the JSONSerializableWithType interface which includes a method called serialize() that Jackson calls, when trying to serialize an Object instance to JSON.</p>
  
  <p>Strangely this serialize method is called correctly as long as my Object wrapper does not extend LinkedHashMap&lt;...>.
  If my Object wrapper extends a Class that Jackson "knows" how to serialize in a default way, the serialize() method is not called anymore.</p>
  
  <p>My wrapper class looks like this:</p>
  
  <pre><code>public class ResponseRoomOccupancy
      extends LinkedHashMap&lt;...&gt;
      implements org.codehaus.jackson.map.JsonSerializableWithType {
  
      @Override
      public void serialize(JsonGenerator jgen, SerializerProvider provider)
              throws IOException, JsonProcessingException {
  
          jgen.writeStartObject();
          // actual serialization of the object
          jgen.writeEndObject();
      }
  
      @Override
      public void serializeWithType(JsonGenerator jgen,
              SerializerProvider provider, TypeSerializer typeSer)
              throws IOException, JsonProcessingException {
          serialize(jgen, provider);
      }
  }
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>@RequestMapping(value = "/occupancy")
  public @ResponseBody ResponseRoomOccupancy
  getRoomOccupancy(RequestRoomOccupancy request) {
  
      return appointmentService.getEnrichedRoomOccupancy(request);
  }
  </code></pre>
  
  <p>Can anybody explain to me why Jackson does not use the custom-defined serialize method on a class that extends LinkedHashMap?</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>As Sotirios Delimanolis pointed out correctly, the JSONSerializableWithType interface is part of an older version of Jackson (&lt;1.9).
  However I dont know why this kind of custom serialization works with custom defined classes (e.g. if LinkedHashMap is exchanged with some class Foo&lt;...>).</p>