Say I have a Mongo document that looks like this
{'_id' : NumberLong(123),
'sites' : [{'One',1}, {'Two',2}]
}
If I have a BSONObject in Java that maps this, say boop, would a BSONObject or a converted to a Java native object be returned if I return a field value?
For example, boop.get('sites') would return a BSONObject that represents an array or
a Java list<Map<String,Integer>>?
Edit:
Documentation in the Mongo Java Driver says that the method returns an Object. I am going to assume that it means a converted object, like in a JSON library, but I want to make sure.
If I understood your question correctly, then the type of boot.get('sites') will be BasicDBList
db.testing.findOne()
{ "_id" : 1, "x" : [ 1, 2, 3 ] }
db.getCollection("testing").findOne().get("x") instanceof BasicDBList : true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With