b <- mongo.bson.from.list(list(name="John", age=32L,
address=list(street="Vine", city="Denver", state="CO")))
iter <- mongo.bson.find(b, "age")
print(mongo.bson.iterator.value(iter)) # print 32
iter <- mongo.bson.find(b, "address.city")
print(mongo.bson.iterator.value(iter)) # print Denver
x <- c(1,1,2,3,5)
b <- mongo.bson.from.list(list(fib=x))
iter <- mongo.bson.find(b, "fib.3") # BSON arrays are 0-based
print(mongo.bson.iterator.value(iter)) # print 3
Run the code above in your browser using DataLab