title: Java.util.Map to JSON Object with Jersey / JAXB / Jackson
body: <p>I've been trying to create a Jersey REST Webservice. I want to receive and emit JSON objects from Java classes like the following:</p>
  
  <pre><code>@XmlRootElement
  public class Book {
  
      public String code;
  
      public HashMap&lt;String, String&gt; names;
  
  }
  </code></pre>
  
  <p>This should be converted into JSON like this:</p>
  
  <pre><code>{
      "code": "ABC123",
      "names": {
          "de": "Die fabelhafte Welt der Amelie",
          "fr": "Le fabuleux destin d'Amelie Poulain"
      }
  }
  </code></pre>
  
  <p>However I can not find a standard solution for this. Everybody seems to be implementing his own <a href="http://java.net/jira/browse/JERSEY-551" rel="noreferrer">wrapper</a> <a href="http://djna.wordpress.com/2010/04/08/json-strings-and-java-objects/" rel="noreferrer">solution</a>. This requirement seems extremly basic to me; I can't believe that this is the generally accepted solution to this, especially since Jersey is really one of the more fun parts of Java.</p>
  
  <p>I've also tried upgrading to Jackson 1.8 which only gives me this, which is extremly obfusicated JSON:</p>
  
  <pre><code>{
      "code": "ABC123",
      "names": {
          "entry": [{
              "key": "de",
              "value": "Die fabelhafte Welt der Amelie"
          },
          {
              "key": "fr",
              "value": "Le fabuleux destin d'Amelie Poulain"
          }]
      }
  }
  </code></pre>
  
  <p>Are there any proposed solutions for this?</p>