【发布时间】:2016-08-12 23:38:57
【问题描述】:
我正在尝试将 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将被转换为schema:
[{"symbol": "VAMP4", "_id": {"$oid": "57ae3b175a945932fcbdf41d"}, "id_entrez": 8674}, {"symbol": "CCT5", "_id": {"$oid": "57ae3b175a945932fcbdf41e"}, "id_entrez": 22948}]
请注意,bjson 的“_id”为 ObjectId - “$oid”。这是因为使用mongodb查询的结果。
请问,有谁知道为什么不能正确地从 bjson 转换为 marshmallow 模式?
谢谢大家!
【问题讨论】:
标签: python mongodb marshmallow