要在java中映射的DBObject
我需要把MongoDB的结果放在地图上。我的代码是要在java中映射的DBObject,java,mongodb,Java,Mongodb,我需要把MongoDB的结果放在地图上。我的代码是 DBCollection collection = db.getCollection("template"); DBCursor cursor = collection.find(allQuery, removeIdProjection); DBObject resultElement = null; resultElement = cursor.next(); 结果是: {“GraphLabel”:“工单数量”,“XaxisLabel”:
DBCollection collection = db.getCollection("template");
DBCursor cursor = collection.find(allQuery, removeIdProjection);
DBObject resultElement = null;
resultElement = cursor.next();
结果是:
{“GraphLabel”:“工单数量”,“XaxisLabel”:“2012年”,
“YaxisLabel”:“卷(k)”,“ShowLegend”:“假”,“查询”:
“从中选择sd.季节\ id、sd.季节、计数(fsf.缺陷\类型\ id
m2m.season\u dim sd,m2m.field\u service\u fact fsf,其中fsf.season\u id=
sd.seasure\u id按sd.seasure\u id“}分组
需要将值与MAP或POJO一起放入。。有人能帮忙吗?这个
DBObject
有一个toMap()
方法,可以将它转换成map下面的代码可以:
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;
DBCollection collection=db.getCollection(“模板”);
DBCursor=collection.find(allQuery,RemoveidProject);
Document doc=cursor.next();//已是地图兼容对象的
Map mDoc=doc;
我不想使用Jackson的可能副本。。。