I want to convert the following json
structure to BasicDBOject
in java and insert into mongo db.
My JSON structure is
{
"it": {
"batch": "2013",
"students": [
{
"name": "joe"
},
{
"name": "john"
}
]
}
}
com.mongodb.util.JSON has a parse method.
BasicDBObject implements DBObject
Object o = com.mongodb.util.JSON.parse("Your JSON structure or JSONObj.toString()");
DBObject dbObj = (DBObject) o;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With