bsoncxx::document::value doc_value = bsoncxx::builder::basic::make_document( bsoncxx::builder::basic::kvp("is_active", true) ); bsoncxx::document::view doc_view = doc_value.view(); bool is_active = doc_view["is_active"].get_bool();
bsoncxx::document::value doc_value = bsoncxx::builder::basic::make_document( bsoncxx::builder::basic::kvp("can_edit", false) ); bsoncxx::document::view doc_view = doc_value.view(); bool can_edit = doc_view["can_edit"].get_bool();In this example, we are constructing a BSON document using the builder interface and setting a boolean field "can_edit" to false. Then, we are retrieving the value of the "can_edit" field using the getBoolField function, which returns a boolean value. Package library: bsoncxx library