MongoDB Java驱动程序聚合字符串
我得到一个结构为JSONArray[{abc:123},{def:456}]的字符串,我需要使用它来调用mongoCollection.aggregatetheStringMongoDB Java驱动程序聚合字符串,mongodb,mongodb-java,Mongodb,Mongodb Java,我得到一个结构为JSONArray[{abc:123},{def:456}]的字符串,我需要使用它来调用mongoCollection.aggregatetheString 聚合函数takes List我能想到这个,但它看起来有点难看 JSONArray array = new JSONArray(theString); List<Document> list = new ArrayList<>(); for(Object
聚合函数takes List我能想到这个,但它看起来有点难看
JSONArray array = new JSONArray(theString);
List<Document> list = new ArrayList<>();
for(Object jsonObject : jsonArray){
Document document = Document.parse(jsonObject.toString());
list.add(document);
}
collection.aggregate(list);