Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
要在java中映射的DBObject_Java_Mongodb - Fatal编程技术网

要在java中映射的DBObject

要在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”:

我需要把MongoDB的结果放在地图上。我的代码是

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的可能副本。。。