What you have here is a bunch of value-fields stored in DBObject
s stored in DBList
s stored in DBObject
s stored in DBList
s stored in DBObject
s iterated by a DBCursor
. Due to this convoluted document-structure you need to walk through this whole tree when you want to output only those on a specific leaf of it.
while (cursor2.hasNext()) {
// you are now iterating a list objects with three Fields:
// FirstOne, SecondOne and ThirdOne. You only want ThirdOne
obj = cursor2.next();
map = obj.toMap();
DBList thirdOne = (DBList)map.get("ThirdOne");
// now we iterat the list in ThirdOne
for (Object o: thirdOne) {
DBObject thirdOneEntry = (DBObject)o;
// we get the explicitElements-array from each entry
DBList explicitElements = (DBList)thirdOneEntry.get("explicitElements");
// now we iterate the expliciteElements
for (Object o: explicitElements) {
DBObject explicitElementsEntry = (DBObject)o;
// and write them
Object key = explicitElementsEntry.get("key");
Object value = explicitElementsEntry.get("value");
System.out.println("Key : " + key.toString() + " Value : " value.toString());
}
}
}