Is it possible to construct JSON with deeply nested resources that fits jsonapi.org format?
E.g. there is such models:
testing
which has many questions
which has many answers
Here is how it can look without jsonapi:
{
"testing": {
"name": "Testing 1",
"questions": [
{
"name": "Question 1",
"answers": [
{"name": "Answer 1.1"},
{"name": "Answer 1.2"},
]
},
{
"name": "Question 2",
"answers": [
{"name": "Answer 2.1"},
{"name": "Answer 2.2"},
]
}
]
}
}
But I think it is impossible to construct it with “relationships” attribute.
What do you reckon, is it possible to provide such kind of data in one JSON document,
where to add answers relationships for each question:
{
"data": [{
"type": "testings",
"id": "1",
"attributes": {
"name": "Testing 1"
},
"relationships": {
"questions": {
"data": [
{ "type": "questions", "id": "1", "name": "Question 1.1" },
{ "type": "questions", "id": "2", "name": "Question 1.2" }
]
}
}
}, {
"type": "testings",
"id": "2",
"attributes": {
"name": "Testing 2"
},
"relationships": {
"questions": {
"data": [
{ "type": "questions", "id": "3", "name": "Question 2.1" },
{ "type": "questions", "id": "4", "name": "Question 2.2" }
]
}
}
}
]
}
Thanks