Skip to content

Add included objects to serialized JSON #22

@mklocek

Description

@mklocek

In one of my apps using jsonapi-datastore I needed a way to include to result of serialize method an array of complete relationship objects, just like in jsonapi specification. For my purposes, I created this: mklocek/jsonapi-datastore@a955efec9ecaba87a0dde0598232d1822022df3a. Including is optional here and looks like that:

var projectAttributes = {
    attributes: ['title'],
    relationships: ['clients', 'managers'],
    included: {
        clients: {
            attributes: ['name']
        },
        managers: {
            attributes: ['name']
        }
    }
};

project.serialize(projectAttributes);
=> # jsonapi json containing 'included' array

Have you thought about such feature?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions