Skip to content
This repository was archived by the owner on Apr 10, 2023. It is now read-only.
This repository was archived by the owner on Apr 10, 2023. It is now read-only.

Removing one level of nesting #131

@murlakatamenka

Description

@murlakatamenka

Hi, thanks for the library! (glad to find it, coming from Rust 🦀)

I have a following json for which I'd like to remove one level of nesting:

{
    "id": 256,
    "title": "Super Album",
    "release_date": "2000-01-02",
    "artist": {
        "id": 42,
        "name": "Some Name"
    },
    "tracks": {
        "data": [
            {
                "id": 123,
                "title": "Track Title"
            }
        ]
    }
}

Deserialization uses following classes it with following classes:

class Artist(Model):
    name: fields.Str()


class Track(Model):
    id: fields.Int()
    title: fields.Str()


class TracksData(Model):
    data: fields.List(Track)


class Album(Model):
    title: fields.Str()
    release_date: fields.Optional(fields.Date)
    artist: fields.Nested(Artist)
    tracks: fields.Nested(TracksData)

Is it possible to get tracks as a list of tracks? In the docs there is fields.Flatten and it's possible to specify deserializers for a field, but I struggle with it and ask for some help. Thanks 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions