I'm trying to convert bjson structure to a schema in marshmallow library.
Below is the marshmallow schema:
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.")
Below is the bjson will be converted to schema:
[{"symbol": "VAMP4", "_id": {"$oid": "57ae3b175a945932fcbdf41d"}, "id_entrez": 8674}, {"symbol": "CCT5", "_id": {"$oid": "57ae3b175a945932fcbdf41e"}, "id_entrez": 22948}]
Note that the bjson has the "_id" as ObjectId - "$oid". This is because the result of the query using the mongodb.
Please, does anyone know why not be to convert from bjson to marshmallow schema correctly ?
Thank you all!