question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help to deserialize complex JSON

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lafrechcommented, Jul 5, 2018

Pluck is work in progress. It is not available yet.

1reaction
deckar01commented, Jul 5, 2018

What version of marshmallow are you using? Can you edit your example so that the data and the schema match?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Deserialize a Complex JSON Object in C# .NET
In this article, we are gonig to learn how to deserialize a complex JSON object using C# as our language of choice.
Read more >
How do I deserialize a complex JSON object in C# .NET?
var jobject = JsonConvert.DeserializeObject<RootObject>(jsonstring);. You can paste the json string to here: http://json2csharp.com/ to check ...
Read more >
Serialize and Deserialize complex JSON in Python
JSON Object is defined using curly braces{} and consists of a key-value pair. It is important to note that the JSON object key...
Read more >
Deserializing The Complex JSON Object In C# - C# Corner
Serializing and deserializing the JSON object in C# is pretty simple with Newtonsoft.Json NuGet package in C#. In this blog, I'm going to ......
Read more >
How to: Deserialization of nested JSON - Dofactory
How to: Deserialization of nested JSON. I am receiving the JSON formatted string from a web service over the Internet. It is roughly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found