buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.bool(buf, "wise", TRUE)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form { "wise" : true }
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.bool(buf, "bools", c(TRUE, FALSE, FALSE))
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "bools" : [true, false, false] }
buf <- mongo.bson.buffer.create()
flags <- c(FALSE, FALSE, TRUE)
names(flags) <- c("Tall", "Fat", "Pretty")
mongo.bson.buffer.append.bool(buf, "Looks", flags)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "Looks" : { "Tall" : false, "Fat" : false, "Pretty" : true } }
Run the code above in your browser using DataLab