Reputation: 309
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 = cursor.next();
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?
Upvotes: 3
Views: 7196
Reputation: 11
Below Code would do:
DBCollection collection = db.getCollection("template");
DBCursor cursor = collection.find(allQuery, removeIdProjection);
Document doc = cursor.next(); // Which is already a Map compatible object
Map <String, Object> mDoc = doc;
Upvotes: 1