buf <- mongo.bson.buffer.create()
code <- mongo.code.create("y = x")
mongo.bson.buffer.append(buf, "Code", code)
lst <- list(c1 = code, One = 1)
mongo.bson.buffer.append.list(buf, "listWcode", lst)
mongo.bson.buffer.append.code(buf, "Code2", "a = 1")
b <- mongo.bson.from.buffer(buf)
# the above will create a mongo.bson object of the following form:
# { "Code": (CODE) "y = x",
# "listWcode" : { "c1" : (CODE) "y = x",
# "One" : 1 },
# "Code2" : (CODE) "a = 1" }
Run the code above in your browser using DataLab