user2572739 user2572739 - 1 month ago 15
Java Question

DBObject to Map in java

I need to put the result from MongoDB in Map. My code is

DBCollection collection = db.getCollection("template");
DBCursor cursor = collection.find(allQuery, removeIdProjection);
DBObject resultElement = null;
resultElement =;

and the result Json is:

{ "GraphLabel" : "Volume Of Work Orders" , "XaxisLabel" : "2012" ,
"YaxisLabel" : "volume(k)" , "ShowLegend" : "FALSE" , "query" :
"select sd.season_id,sd.season, count(fsf.defect_type_id) from
m2m.season_dim sd ,m2m.field_service_fact fsf where fsf.season_id =
sd.season_id group by sd.season_id"}

Need to put the values with MAP or POJO .. Can somebody help please?


The DBObject has a toMap() method which transforms it into map