buf <- mongo.bson.buffer.create()
l <- list(fruit = "apple", hasSeeds = TRUE)
mongo.bson.buffer.append.list(buf, "item", l)
b <- mongo.bson.from.buffer(buf)
# this produces a BSON object of the form:
# { "item" : { "fruit" : "apple", "hasSeeds" : true } }
Run the code above in your browser using DataLab