title: How to retain map having null values in the jackson
body: <pre><code>HashMap testMap = new HashMap();
  testMap.put("Key1", "Value1");
  testMap.put("Key2", null);  
  
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.enableDefaultTyping(); 
  objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL,JsonTypeInfo.As.WRAPPER_OBJECT);          
  objectMapper.setVisibility(PropertyAccessor.SETTER,JsonAutoDetect.Visibility.NONE);
  objectMapper.setVisibility(PropertyAccessor.GETTER,JsonAutoDetect.Visibility.NONE);
  objectMapper.setVisibility(PropertyAccessor.FIELD,JsonAutoDetect.Visibility.ANY);
  objectMapper.setVisibility(PropertyAccessor.IS_GETTER,JsonAutoDetect.Visibility.NONE);          
  //objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
  
  String jsonString = objectMapper.writeValueAsString(testMap);
  System.out.println(jsonString);
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <pre><code>objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
  </code></pre>
  
  <p>a) When I use above statement and executes, it's throwing below exception. </p>
  
  <pre><code>java.lang.UnsupportedOperationException: Type id handling not implemented for type java.lang.Object
      at com.fasterxml.jackson.databind.JsonSerializer.serializeWithType(JsonSerializer.java:142)
      at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeTypedFields(MapSerializer.java:798)
  
  objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
  </code></pre>
  
  <p>b) When I use the above statement and executes, it's working fine, but result is like below,</p>
  
  <pre><code>{"java.util.HashMap":{"Key1":"Value1"}}
  </code></pre>
  
  <p>But Key2 is removed from the json. So how to retain null values?</p>
  
  <pre><code>objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
  </code></pre>
  
  <p>c) When i usethe above statement and executes with jackson-databind.jar (version 2.7)
  It working and retained null values also.
  But jackson-databind version 2.7 supports jdk 7 onwards.So how can i use same thing in jdk 6 version?</p>
  
  <p>Let me know any other alternatives to overcome it.</p>