我得到以下输出
for( Iterator <Object> it = results2.iterator();it.hasNext();)
{
BasicDBObject result = (BasicDBObject) it.next();
BasicDBObject dbo = (BasicDBObject) result.get("obj");
String title2=(String) dbo.getString("Filename");
system.out.println("filename"+title2);
JsonArray finalResult = null;
JsonParser parser = new JsonParser();
String tags2=dbo.getString("Tags");
JsonElement elem = parser.parse(tags2);
finalResult = elem.getAsJsonArray();
for(int i=0;i<finalResult .size();i++)
{
JsonElement keys=finalResult.get(i);
System.out.println("final Result:"+keys);
}
}
输出:
filename:sample.pdf
finalresult:"java"
"pdf"
"c++"
filename:sample1.pdf
finalresult:"java1"
"pdf"
"c+"
但我希望通过删除重复项来获取所有文件的整体标记
filename:sample.pdf
filename:sample1.pdf
finalresult:"java"
"pdf"
"c++"
"java1"
"c+"
我在mondodb中的标记字段是
["java","php","c++]
你能建议我怎么做吗
感谢