Parsing_and_Iterating_BSON_Documents(3) None

RECURSING INTO SUB-DOCUMENTS

Libbson provides convenient sub-iterators to dive down into a sub-document or sub-array. Below is an example that will dive into a sub-document named "foo" and print it's field names.

FINDING FIELDS USING DOT NOTATION

Using the bson_iter_recurse(3) function exemplified above, bson_iter_find_descendant(3) can find a field for you using the MongoDB style path notation such as "foo.bar.0.baz".

Let's create a document like {foo: {bar: [{baz: 1}]}} and locate the baz field.

VALIDATING A BSON DOCUMENT

If all you want to do is validate that a BSON document is valid, you can use bson_validate(3) \&.

See the bson_validate(3) documentation for more information and examples.

COLOPHON

This page is part of libbson. Please report any bugs at https://jira.mongodb.org/browse/CDRIVER.