name <- mongo.bson.from.list(list(first="Joe", last="Smith"))
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.bson(buf, "name", name)
mongo.bson.buffer.append.string(buf, "city", "New York")
b <- mongo.bson.from.buffer(buf)
# the above will create a mongo.bson object of the following form:
# { "name" : { "first" : "Joe", "last" : "Smith" }, "city" : "New York" }
Run the code above in your browser using DataLab