Convert between pjm and bson