title: How to convert json Object to Document in mongodb using java
body: <p>I'm using the below sample json :</p>
  
  <pre><code>JSONObject json=new JSONObject();
              json.put("time_range", "22-23");
              json.put("flow_id", "786");
  </code></pre>
  
  <p>And trying to convert to Document as follows :</p>
  
  <pre><code>Document doc = (Document) JSON.parse(jsonlist.toString()); // conversion from json to Document
  
  col.insertOne(doc); // inserting into Mongo collection
  </code></pre>
  
  <p>I'm facing the below error:</p>
  
  <pre><code> java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to org.bson.Document    
  </code></pre>
  
  <p>Can anyone please help me out regarding this issue ...</p>