我的代码是
DBCollection collection = db.getCollection("volume");
DBCursor cursor = collection.find();
DBObject resultElement = cursor.next();
Map resultElementMap = resultElement.toMap();
System.out.println(resultElementMap);
Run Code Online (Sandbox Code Playgroud)
结果是:
{_id = 521b509d20954a0aff8d9b02,title = {"text":"工作量订单","x": - 20.0},xAxis = {"title":{"text":"2012"},"categories":[" Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},yAxis = {"min":1000.0,"max":7000.0,"title":{"text":"Volume(K)"},"plotLines":[{"label":{"text":"Average", "x":25.0},"color":"black","width":2.0,"value":30.0,"dashStyle":"solid"}]},legend = {"backgroundColor":"#FFFFFF", "reversed":true},series = [{"name":"Volume","showInLegend":false,"data":[2909.0,3080.0,4851.0,3087.0,2960.0,2911.0,1900.0,3066.0,3029.0,5207.0, 3056.0,3057.0]}]}
我需要从结果中删除_id.我知道我需要和collection.find()一起玩,但请有人帮助我吗?我无法获得结果
我需要将MongoDB的结果放在Map中.我的代码是
DBCollection collection = db.getCollection("template");
DBCursor cursor = collection.find(allQuery, removeIdProjection);
DBObject resultElement = null;
resultElement = cursor.next();
Run Code Online (Sandbox Code Playgroud)
结果Json是:
{"GraphLabel":"工作量订单","XaxisLabel":"2012","YaxisLabel":"volume(k)","ShowLegend":"FALSE","query":"select sd.season_id,sd .season,count(fsf.defect_type_id)来自m2m.season_dim sd,m2m.field_service_fact fsf其中fsf.season_id = sd.season_id group by sd.season_id"}
需要将值与MAP或POJO放在一起..有人可以帮忙吗?