buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append(buf, "name", "Fred")
mongo.bson.buffer.append(buf, "city", "Dayton")
b <- mongo.bson.from.buffer(buf)
# all display the same thing
mongo.bson.print(b)
print.mongo.bson(b)
print(b)
Run the code above in your browser using DataLab