Hi all, I have a ResourceA with nested objects:
{
"data": [
{
"type": "resource_a",
"id": "some-unique-id-here",
"attributes": {
"key1": "value1",
"key2": "value2",
"fee": {
"price": 1245.56,
"value": 123.99
},
"changes": [
{
"value": 0,
"price": 0
},
...
]
}
}
]
}
Everything is ok, because specification says:
Attributes may contain any valid JSON value, including complex data structures involving JSON objects and arrays.
But I also have to add related ResourceB to both fee and every change in the list:
{
"data": [
{
"type": "resource_a",
"id": "some-unique-id-here",
"attributes": {
"key1": "value1",
"key2": "value2",
"fee": {
"resource_b": ????,
"price": 2542.23,
"value": 39.965672931101786
},
"changes": [
{
"resource_b": ????,
"value": 0,
"price": 0
}
]
}
}
]
}
But it does not seem valid, because the specification says:
Keys that reference related resources (e.g.
author_id
) SHOULD NOT appear as attributes. Instead, relationships SHOULD be used.
Thus I can’t add nor resourceb_id or resource object itself. I don’t have any separate resources for fees and changes, how can I handle this use case?