0

I am trying to get the value of an element in a nested Bson document using MongoDB driver. The document outline is something like this:

_id  >> 1-4OUKQQ
type >> person
name >> john
surname >> blogg
details >> { "sid" : "456", "height" : "1.8m"}

I would like to "get the value" of "height" which is a nested list of elements in the document. I would like to do something like

mHeight = element.details.height

and get a value of "1.8m"

without the need to do expensive looping to find the value of element = detail.height

n/a please see above.

David Tait
  • 11
  • 1
  • 2
  • A good deserialization library should support it, assuming the correct destination class definition. I'm not familiar with the available tooling for what you're doing, so I don't know if it's actually set up for that. – Craig Nov 03 '22 at 14:51
  • if you use .net driver, then it should be: element["details"]["height"] – dododo Nov 03 '22 at 15:44
  • @dododo For VB, that would almost certainly be `element("details")("height")`. – Craig Nov 03 '22 at 17:07
  • might be, in other words, you should use indexer in what ever way VB allows doing it – dododo Nov 03 '22 at 17:13

0 Answers0