MongoDB extracting values from BasicDBObject (Java)

There’s no way to chain a property name like you’re doing using the Java driver (gets for sure, and according to the this, put isn’t supposed to work either).

You’ll need to get the objects one at a time like you suggested.

((DBObject)obj.get("response")).get("resData")

See here for a potential future feature that would allow your syntax to possibly work (although, likely with a new method name).

Leave a Comment