I have the following String which is returning from the Database in the form of List, My assumption is that, the list contains 3 items. but it is showing only "1" as the size. So it is returning all the activity items as one element.
Note: When I try to get the first index of the list (list.get(0)), it returns only one "activity" not all the three(as a single item).I don't know what is happening inside the list.
My Question: How to convert the below list of strings which contains 1 item(with 3 activity items) into List which should consider list size as 3(3 activity).
[ { "activity" : { "id" : "a_3" , "kind" : "Infomation" , "userId" : 100 , "accountId" : 0 , "timestamp" : 1476369009366 , "result" : "normal" }} ,
{ "activity" : { "id" : "a_18" , "kind" : "Infomation" , "userId" : 100 , "accountId" : 0 ,"timestamp" : 1476419696003 , "result" : "normal" }} ,
{ "activity" : { "id" : "a_4" , "kind" : "Infomation" , "userId" : 100, "accountId" : 0 , ""timestamp" : 1476435910335 , "result" : "normal" }}]
The above information is from the DB:
Iterable<DBObject> results =null;
List<String> retList = new ArrayList<>();
try {
results= collection.aggregate(pipeline).results();
} catch (Exception e) {
}
if(results!=null){
Iterator<DBObject> iterator = results.iterator();
while (iterator.hasNext()) {
String input = iterator.next().get("actLogList").toString();
retList.add(input.substring(input.indexOf("[") + 1, input.lastIndexOf("]")));
}
}
return retList;