title: Map deserializing with Jackson in Java
body: <p>I have the following class</p>
  
  <pre><code>public class BetWrapper {
  
      private String description;
      private Calendar startTime;
      private HashMap&lt;String, SimpleEntry&lt;Integer, Double&gt;&gt; map;
  
  
      public BetWrapper() {
          map = new HashMap&lt;&gt;();
      }
  
      public Calendar getStartTime() {
          return startTime;
      }
  
      public void setStartTime(Calendar startTime) {
          this.startTime = startTime;
      }
  
      public String getDescription() {
          return description;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public HashMap&lt;String, SimpleEntry&lt;Integer, Double&gt;&gt; getMap() {
          return map;
      }
  
      public void setMap(HashMap&lt;String, SimpleEntry&lt;Integer, Double&gt;&gt; map) {
          this.map = map;
      }
  
  }
  </code></pre>
  
  <p>And I'm using JSONUtil class</p>
  
  <pre><code>public class JSONUtil {
  
      private JSONUtil() {}
  
      public static &lt;T&gt; T fromJSON(String content, Class&lt;T&gt; clazz) throws TechnicalException {
          try {
              return new ObjectMapper().readValue(content, clazz);
          } catch (IOException e) {
              throw new TechnicalException(e);
          }
      }
  
      public static String toJSON(Object obj) throws TechnicalException {
          try {
              return new ObjectMapper().writeValueAsString(obj);
          } catch (JsonProcessingException ex) {
              throw new TechnicalException(ex);
          }
      }
  
  }
  </code></pre>
  
  <p>I want to deserialzize a JSON to an BetWrapper object. But the following code produces some exceptions.</p>
  
  <pre><code>BetWrapper betWrapper = new BetWrapper();
  betWrapper.setDescription("Stoke City - Arsenal");
  betWrapper.setStartTime(Calendar.getInstance());
  HashMap&lt;String, AbstractMap.SimpleEntry&lt;Integer, Double&gt;&gt; map = new HashMap&lt;&gt;();
  map.put("home_team", new AbstractMap.SimpleEntry&lt;&gt;(1, 2.85));
  betWrapper.setMap(map);
  String json = JSONUtil.toJSON(betWrapper);
  JSONUtil.fromJSON(json, BetWrapper.class);
  </code></pre>
  
  <p>The exceptions are:</p>
  
  <pre><code>Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class java.util.AbstractMap$SimpleEntry&lt;java.lang.Integer,java.lang.Double&gt;]: can not instantiate from JSON object (need to add/enable type information?)
  at [Source: {"description":"Stoke City - Arsenal","startTime":1417648132139,"map":{"home_team":"key":1,"value":2.85}}}; line: 1, column: 85] (through reference chain: by.bsu.kolodyuk.bettingapp.model.entity.BetWrapper["map"])
  </code></pre>
  
  <p>How to deserialize it correctly? It seems like that the problem is that types K,V in SimpleEntry should be specified for Jackson in some way.</p>
  
  <p>Any Ideas?</p>