我想使用java获取内部嵌套元素。我应该怎么做呢? mongodb数据库结构如下。我想获取每个JSONArray的最后一个JSONObject。
{
"_id" : ObjectId("527242d584ae917d8bd75c7b"),
"messages" : [
{
"from" : "test",
"message" : "heelo",
"received" : true,
"audioUrl" : "h",
"date" : ISODate("2019-03-16T20:57:47.536Z")
},
{
"from" : "test", //want this message
"message" : "heelo",
"received" : true,
"audioUrl" : "h",
"date" : ISODate("2019-03-16T20:57:47.536Z")
}
]
}
{ “ _id”:ObjectId(“ 5c8d64804581275945d629ae”), “ to”:“ abcs”, “消息”:[ { “ from”:“ test”, “ message”:“ heelo”, “已接收”:是的, “ audioUrl”:“ h”, “ date”:ISODate(“ 2019-03-18T10:17:20.988Z”) }, { “ from”:“ test”,//还有这个 “ message”:“ heelo”, “已接收”:是的, “ audioUrl”:“ h”, “ date”:ISODate(“ 2019-03-18T10:18:52.249Z”) } ] }