Make object2json to handle mongoengine Document and bson ObjectId