E
E
Evgenii Borovoi2020-05-22 12:40:59
JSON
Evgenii Borovoi, 2020-05-22 12:40:59

When I give a resource, should the user's data be written in atributes or at the same level as id and type in the JSON API?

Attention, the question is strictly on this specification: JSON API , not just JSON.
Actually, it should be like this:

{
  "type": "user",
  "id": "1",
  "attributes": {
    "name": "Dima",
    "email":"[email protected]"
  },
  },

Or like this:
{
  "type": "user",
  "id": "1",
   "name": "Dima",
   "email":"[email protected]",
  "attributes": {
  },
  },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgenii Borovoi, 2020-05-23
@EugeneOne77

He asked, he answered.
Still, all data must be written in attributes, i.e. first option. Here
is an example .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question