I have a json:
[{
"myKey": "key"
}]
My schema is:
_snake_case = re.compile(r"(?<=\w)_(\w)")
_to_camel_case = partial(_snake_case.sub, lambda m: m[1].upper())
class CamelCasedSchema(Schema):
"""Gives fields a camelCased data key"""
def on_bind_field(self, field_name, field_obj, _cc=_to_camel_case):
field_obj.data_key = _cc(field_name.lower())
class KeySchema(CamelCasedSchema):
my_key = fields.String(required=True, data_key="myKey")
I am loading it as:
KeySchema(many=True).load(json)
I want that the json [{ "myKey": "key" }] gets converted to schema and i can get my_key as key.
Right now i am getting:
Original Error {0: {'my_key': ['Missing data for required field.']}}
What am i missing here?
marshmallow version is 3.0.0rc1