title: How to convert POJO to Map and vice versa in Java?
body: <p>My use case is to convert any arbitrary POJO to Map and back from Map to POJO. So I ended up using the strategy POJO -> json -> org.bson.Document and back to org.bson.Document -> json -> POJO. </p>
  
  <p>I am using gson to convert POJO to json, </p>
  
  <pre><code>Gson gson = new GsonBuilder().create();
  String json = gson.toJson(pojo);
  </code></pre>
  
  <p>then</p>
  
  <pre><code>Document doc = Document.parse(json); 
  </code></pre>
  
  <p>to create the document and it is easy. But other way around is problematic. <code>document.toJson()</code> is not giving standard json for long, timestamp etc and gson is complaining while deserialising to POJO. So I need a way to convert org.bson.Document to standard json.</p>
  
  <p>NOTE: I want to avoid using mongo java driver or morphia as this work does not relate to mongo in anyway.</p>