title: Converter from Gson to MongoDB objects
body: <p>Is anyone aware of a converter to transform from Gson to DBOjects for MongoDB, similarly to <a href="https://code.google.com/p/mongo2gson/" rel="nofollow">https://code.google.com/p/mongo2gson/</a> but in the other direction (i.e. gson2mongo)?</p>
  
  <p>My aim is to convert a string (which is a valid JSONArray) into a DBObject, so that I can insert it into a Mongo database.  There seems to be a standard technique for converting JSON objects into DBObject i.e</p>
  
  <pre><code>DBObject dbObject = (DBObject) JSON.parse("some json object string");
  </code></pre>
  
  <p>However, this approach does not work for JSONArrays and there doesn't seem to be a simple alternative.  I've seen a few hacks that work for very simple JSONArrays, but nothing that could be used on a more complex structure. The gson library has some really useful stuff, and in the link above, this problem has been solved in one direction - (it allows you to convert from DBObjects to JsonArrays) but not the other way.  Hopefully that's a little clearer!</p>