The default behaviour of deserialize() seems to be to return an array of relationships keys. If the top-level key "included" is set, it returns the relationships as an object with an 'id' key however.
For example:
{
"data": {
"id": 1,
"attributes": {
"name": "randomname"
},
"relationships": {
"roles": {
"data": {
"type": "role",
"id": 1
}
}
}
}
}
deserializes to { id: 1, name: 'randomname', roles: 1 }.
{
"data": {
"id": 1,
"attributes": {
"name": "randomname"
},
"relationships": {
"roles": {
"data": {
"type": "role",
"id": 1
}
}
}
},
"included": [{
"type": "role",
"id": 1
}]
}
deserializes to: { id: 1, name: 'randomname', roles: { id: 1 } }
Now, I would like to get the second result, but the JSON API spec doesn't seem to require the "included" key on updates: https://jsonapi.org/format/#crud-updating-resource-relationships
So I am wondering, is there a specific reason why the result of deserialization differs when the "included" key exists in the request?
The default behaviour of deserialize() seems to be to return an array of relationships keys. If the top-level key "included" is set, it returns the relationships as an object with an 'id' key however.
For example:
deserializes to
{ id: 1, name: 'randomname', roles: 1 }.deserializes to:
{ id: 1, name: 'randomname', roles: { id: 1 } }Now, I would like to get the second result, but the JSON API spec doesn't seem to require the "included" key on updates: https://jsonapi.org/format/#crud-updating-resource-relationships
So I am wondering, is there a specific reason why the result of deserialization differs when the "included" key exists in the request?