I check the python data in marshmallow, the food field is a list, and the list stores the dict. I can only do this step. In fact, I want to verify that the value in the dict is int instead of string. How should I modify my code?
from marshmallow import Schema, fields, pprint
class UserSchema(Schema):
name = fields.Str()
food = fields.List(fields.Dict)
user_data = {
"name": "Ken",
"food": [{'apple': 2, 'banana': 4}, {'apple': '2', 'banana': '4'}]
}
result = UserSchema().load(user_data)
pprint(result)