title: Parse Json to DBObject
body: <p>I have a <code>REST</code> service which consumes "<em>test/plain</em>", basically the string I receive is a <code>JSON</code> string, I have the following code to parse the <code>JSON</code> string to <code>DBObject</code> so that I can save it to <code>MongoDB</code>.</p>
  
  <pre><code>@Timed
  @POST
  @Consumes("text/plain")
  @Produces(MediaType.APPLICATION_JSON)
  public Response insertscreenview(String message) {
      // System.out.println(message);
      final Logger logger = LoggerFactory.getLogger(ScreenviewResource.class);
      logger.info("Screenview Insert Request Recieved" + "\n" + message);
      screenviewInstance = new Screenview();
      tracInfoInstance = new TracInfo();
      BasicDBObject ageRangeId;
      GeoCheckManager geoCheckInstance = new GeoCheckManager();
      boolean brCheck;        
      try {
          ObjectMapper mapper = new ObjectMapper();
          JsonNode actualObj = mapper.readTree(message);
  
          System.out.println(message);
  
          DBObject objInstance = (DBObject)JSON.parse(message);
   ...}
  </code></pre>
  
  <p>My <code>JSON</code> string look's as follow </p>
  
  <pre><code>{
  "Screenview": {
      "TracInfo": null,
      "Id": 0,
      "ScreenName": "SettingsActivity",
      "Timestamp": "2014-07-02T18:50:10",
      "Timezone": "Asia/Kolkata",
      "ApplicationId": null,
      "DeviceId": null,
      "UserId": null,
      "SessionId": "5684ae84-9a48-49a5-ab47-fcb7de3c08cf"
  },
  "Session": {
      "Id": "5684ae84-9a48-49a5-ab47-fcb7de3c08cf",
      "StartTime": "2014-07-02T13:20:58",
      "EndTime": "2014-07-02T13:21:09",
      "EntryScreen": "AccessPointActivity",
      "ExitScreen": "SettingsActivity",
      "FirstEvent": "SCREEN STARTED",
      "LastEvent": "SCREEN STOPPED",
      "ApplicationId": "fa41f204bfc711e3b9f9c8cbb8c502c4",
      "DeviceId": "0_6e505bcbe7e511e393b60aba4a7caa0b",
      "UserId": "",
      "TracInfoId": -1,
      "SensorsInfo": null
  },
  "CustomParams": {
      "Latitude": 0,
      "Longitude": 0,
      "Country": null,
      "CountryCode": null,
      "Region": null,
      "RegionCode": null,
      "City": null,
      "Gender": null,
      "Age": 0,
      "Platform": "Android",
      "OSVersion": "16",
      "Manufacturer": "samsung",
      "Resolution": "600 * 976",
      "NetworkCarrier": null,
      "Timezone": null
  } }
  </code></pre>
  
  <p>It gives me error as follow and I am unable to find why.</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.util.HashMap cannot be cast to
    com.mongodb.DBObject</p>
  </blockquote>