title: How to (de)serialize an EnumMap using Jackson and default typing?
body: <p>I have an object in which one of the properties is a <code>Map&lt;MyEnum, Object&gt;</code>.</p>
  
  <p>As my application is quite big, I've enabled default typing as so :</p>
  
  <pre><code>    ObjectMapper jsonMapper = new ObjectMapper()
          .enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT)
          .configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  </code></pre>
  
  <p>This is rather good, generally speaking.</p>
  
  <p>But, as Javascript doesn't support object keys when using objects as hashes, when I put some data in that map from the javascript side, the object is transformed into a string.</p>
  
  <p>As a consequence, the JSON I receive contains</p>
  
  <pre><code>     "MyClass": {
          "contextElements": {
            "userCredentials": {
              "UserCredentials": {
                "login": "admin",
                "password": "admin",
                }
              }
            }
          },
  </code></pre>
  
  <p>When deserializing that, Jackson fails with the following exception</p>
  
  <pre><code>java.lang.IllegalArgumentException: Invalid type id 'userCredentials' (for id type 'Id.class'): no such class found
      at org.codehaus.jackson.map.jsontype.impl.ClassNameIdResolver.typeFromId(ClassNameIdResolver.java:72)
      at org.codehaus.jackson.map.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:61)
      at org.codehaus.jackson.map.jsontype.impl.AsWrapperTypeDeserializer._deserialize(AsWrapperTypeDeserializer.java:87)
      at org.codehaus.jackson.map.jsontype.impl.AsWrapperTypeDeserializer.deserializeTypedFromObject(AsWrapperTypeDeserializer.java:39)
      at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:133)
      at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:221)
  </code></pre>
  
  <p>Which I quite well understand : Jackson doesn't understand the <code>Map&lt;MyEnum, Object&gt;</code> declaration in my class and, although <code>MyEnum</code> is a final class, wants some type metadata added (hey, maybe it's a bug ?!).</p>
  
  <p>What can I do to ahve that code working ?</p>
  
  <p>I'm using Jackson 1.5.2</p>