将JSON结构转换为BasicDBObject

我想将以下json结构转换为java中的BasicDBOject并插入到mongo db中。

我的JSON结构是

 { "it": { "batch": "2013", "students": [ { "name": "joe" }, { "name": "john" } ] } } 

com.mongodb.util.JSON有一个解析方法。

BasicDBObject实现DBObject

 Object o = com.mongodb.util.JSON.parse("Your JSON structure or JSONObj.toString()"); DBObject dbObj = (DBObject) o; 
 com.mongodb.util.JSON.parse 

已弃用

版本3.6.1使用后:

 String json = "{"name": "joe"}"; Object o = BasicDBObject.parse(json); 

按照此处: deprecated-list