BSON parser and encoder