marshmallow-code / marshmallow-code/marshmallow-oneofschema

Help to deserialize complex JSON

Open
#14 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
142
Forks
44
Avg merge
7h 7m
Merged PRs (30d)
3

Description

I need to deserialize this JSON:

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

Into this object using Marshmallow:

```json
{
"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:

```python
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)
```

Contributor guide

Open the contributing guide

Research direction

The issue provides only Python and Marshmallow snippets, with no repository file or test target. Reproduce the shown input and schema behavior first; completion would require documenting a supported mapping and example that produces the requested output, but the issue does not define a code change.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.