Skip to content

Support type in deserialized data #138

@Ayc0

Description

@Ayc0

When running this code:

const serializedData = {
    data: {
        type: 'articles',
        id: '1',
        attributes: {
            type: 'articles',
            type: '123',
            title: 'JSON:API paints my bikeshed!',
        },

    },
};

deserialize(serializedData);

we get

{
  "id": "1",
  "type": "123",
  "title": "JSON:API paints my bikeshed!"
}

The type articles gets lost in the deserialization process. And I don't think we can just pass it top level as this could conflict with a attributes.type field.

What do you think about adding something like Symbol('type')? (would avoid conflicts and give access to the types)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions