I'm consuming an API that returns something like:
{'name': 'foo', 'start': {'date': '2016-06-19', 'time': '18:00'}}
And I want to desearialize it with marshmallow to get only the name and the start date, so the desired result would be the following:
{'name': 'foo', 'date': '2016-06-19'}
But I haven't found any way to get the date, this what I have tried:
from marshmallow import Schema, fields, pprint
event = {'name': 'foo', 'start': {'date': '2016-06-19', 'time': '18:00'}}
class EventSchema(Schema):
name = fields.Str()
date = fields.Str(load_from='start.date')
schema = EventSchema()
result = schema.load(event)
pprint(result.data)