我正在尝试将 bjson 结构转换为棉花糖库中的模式。
下面是棉花糖模式:
class GeneSchema(Schema):
"""description of class"""
id_entrez = fields.Integer(required = True, error_messages={'required': "The 'id_entrez' field is requeired."})
symbol = fields.String()
@validates('id_entrez')
def validate_id_entrez(self, data):
if data <= 0:
raise ValidationError("The 'id_entrez' field must be greater than zero.")
下面是 bjson 将被转换为模式:
[{"symbol": "VAMP4", "_id": {"$oid": "57ae3b175a945932fcbdf41d"}, "id_entrez": 8674}, {"symbol": "CCT5", "_id": {"$oid": "57ae3b175a945932fcbdf41e"}, "id_entrez": 22948}]
请注意,bjson 的“_id”为 ObjectId - “$oid”。这是因为使用 mongodb 的查询结果。
请问,有谁知道为什么不正确地从 bjson 转换为 marshmallow 模式?
谢谢你们!