Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help to deserialize complex JSON #14

Open
vcamaral opened this issue Jul 5, 2018 · 1 comment
Open

Help to deserialize complex JSON #14

vcamaral opened this issue Jul 5, 2018 · 1 comment

Comments

@vcamaral
Copy link

vcamaral commented Jul 5, 2018

I need to deserialize this JSON:

{
    "emails": {
        "items": [
            {
                "id": 1,
                "email": "john@doe.com"
            },
            {
                "id": 2,
                "email": "jane@doe.com"
            }
        ]
    }
}

Into this object using Marshmallow:

{
    "emails": [
        {
            "id": 1,
            "email": "john@doe.com"
        },
        {
            "id": 2,
            "email": "jane@doe.com"
        }
    ]
}

How can I do it?

I tried this way, which I found more intuitive, but it did not work:

class Phone(OrderedSchema):
    id = fields.Int()
    email = fields.Str()

class Contact(Schema):
    key = fields.Str()
    phones = fields.Nested(Phone, load_from='phones.list', many=True)
@lafrech
Copy link
Member

lafrech commented Jul 5, 2018

@vcamaral please close this as duplicate of marshmallow-code/marshmallow#873.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants