如何将bjson结构反序列化为棉花糖方案

2024-09-27 21:31:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将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将转换为架构:

^{pr2}$

请注意,bjson将“\u id”作为ObjectId-“$oid”。这是因为使用mongodb查询的结果。在

请问,有人知道为什么不把bjson模式转换成棉花糖模式?在

谢谢大家!在


Tags: theidfieldfieldsdataschema模式required
1条回答
网友
1楼 · 发布于 2024-09-27 21:31:04

您仍然可以使用模式来解析MongoDB输出,只需忽略额外的“_id”字段。另一方面,如果您确实想解析这个“_id”,只需在模式中添加额外的非必需字段。在

相关问题 更多 >

    热门问题