Skip to content

JSON API compatibility #91

@epyx25

Description

@epyx25

Although the documentation claims that it is JSON API compatible http://ember-graph.com/api/JSONSerializer.html#index, I am having trouble to deserialize a payload

{
  "links":{
    "self":"http://localhost:3001/api/accounts/1?_=1460310632001"
  },
  "data":{
    "type":"accounts",
    "relationships":{
      "roles":{
        "links":{
          "related":"http://localhost:3001/api/accounts/1/roles"
        }
      },
      "company":{
        "links":{
          "related":"http://localhost:3001/api/accounts/1/company"
        }
      }
    },
    "id":"1",
    "attributes":{
      "is-admin":true,
      "username":"admin",
    },
    "links":{
      "self":"http://localhost:3001/api/accounts/1"
    }
  }
}

I am getting the following error

Error: Cannot find model class with typeKey: links

If I remove the links in the deserializer

export default EmberGraph.JSONSerializer.extend({
  deserialize: function (payload, options) {
    console.log(payload);
    delete payload.links;
    return payload;
  }
});

Then it complains about the data property

Error: Cannot find model class with typeKey: data

They are both valid parts of the JSON API specification. http://jsonapi.org/format/#document-top-level

PS.: There is always a parameter added by EG to the end of the requests:

_=1460310632001

Where does it come from, and why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions