我想提取在「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我已更新我的問題,並添加了我的一個試用版 –