Convert JSON to DBObject in Java and MongoDB

MongoDB

Convert JSON to DBObject in Java and MongoDB.

This example shows how to convert JSON data to DBObject in Java using MongoDB database and insert into the collection.

JSON Data to Convert:

{
‘name’ : ‘javac’,
‘age’ : 6
}

Conversion Code:

Output:

{ “_id” : { “$oid” : “4dc9ebb5237f275c2fe4959f”} , “name” : “javac” , “age” : 6}
Done
Share This Post On: