我想提取在“location”字段中提到的所有这些地方,并且不希望下面的json中的其他字段,但无法提取,因为它是嵌套的。可以任何人都帮助我?从mongodb中提取JSON字段的字段
DBCursor cursorTotal = coll.find(obje);
while (cursorTotal.hasNext()) {
DBObject curNext = cursorTotal.next();
System.out.println("data::"+curNext.get("list.myList.location");
}
我 “curNext” 给出输出为::
{
"_id": {
"$oid": "51ebe983e4b0d529b4df2a0e"
},
"date": {
"$date": "2013-07-21T13:31:11.000Z"
},
"lTitle": "Three held for running CISF job racket",
"list": {
"myList": [
{
"location": "Germany"
},
{
"location": "Geneva"
},
{
"location": "Paris"
}
]
},
"hash": -1535814113,
"category": "news"
}
我想我作为
Germany,Geneva,Paris
你到目前为止尝试了什么? – BetaRide
@BetaRide我已更新我的问题,并添加了我的一个试用版 –