如何在java中查询存在MongoDB里的嵌套json格式的数据?
这是我的json数据:
{ "_id" : ObjectId("59eac603b2921c583a1a38c1"), "mj1" : { "source" : 104963,"dj":"mih", "n
umber" : 3, "target" : 100322,"weights" : 122 }, "mj2" : { "source" : 109601,"dj":"mih", "number" : 4, "ta
rget" : 105710,"weights" : 10 } }
{ "_id" : ObjectId("59eac6b7b2921c583a1a38cd"), "mj1" : [ { "source" : 104963,"dj":"mih",
"number" : 3, "target" : 100322,"weights" : 1022 },"mj2" : { "source" : 109601,"dj":"mih", "number" : 4, "target" :
105710,"weights" : 2 } ] }
我先用了这句话( db.mjj.find({"mjj1":{"$ne" : null,$exists : true}}))查询,可以得到如上结果,但是,我只想查询"source","number","target",这三样,该如何编写程序?CMD的命令和JAVA的命令回答都可以。
ibeautiful
相关分类