How to represent folder hierarchy in resourse

i have a folder hierarchy, f1 has a sibling f2 and f1 have 2 sub-olders f11,f12. how do i represent it, because of them are type “folders”, nothing should go in include.
is it possible to have relationship in data referencing its own type.

/folders

{
“data”: [
{
“id”: “f1”,
“type”: “folder”,
“attributes”: {
“name”: “xyz”
},
“relationships”: {
“subFolders”: {
“data”: [
{“id”: “f11”, “type”: “folder”},
{“id”: “f12”,“type”: “folder”}
]
},
“nextFolder”: {
“data”: {“id”: “f2”,“type”: “folder”}
}
},
“links”: {
“delete”: {
“href”: “----”,
“meta”: {
“method”: “DELETE”
}
}
}
},
{
“id”: “f2”,
“type”: “folder”,
“attributes”: {
“name”: “abc”
},
“relationships”: {
“subFolders”: {
“data”: [
{“id”: “f21”, “type”: “folder”},
{“id”: “f22”,“type”: “folder”}
]
},
},
“links”: {
“delete”: {
“href”: “—”,
“meta”: {
“method”: “DELETE”
}
}
}
},
{
“id”: “f11”,
“type”: “folder”,
“attributes”: {
“name”: “qwe”
},
“relationships”: {
“nextFolder”: {
“data”: {
“id”: “f12”,
“type”: “folder”
}
}
},
“links”: {
“delete”: {
“href”: “—”,
“meta”: {
“method”: “DELETE”
}
}
}
},
{
“id”: “f12”,
“type”: “folder”,
“attributes”: {
“name”: “fgfg”
},
“links”: {
“delete”: {
“href”: “----”,
“meta”: {
“method”: “DELETE”
}
}
}
}
]
}

A relationship like subFolders sounds like a good solution. Not sure what you mean the problem is, or what you mean by “nothing should go in include”.

Also, please use code blocks to format your JSON; it’s impossible to read as it is now. :slight_smile:

1 Like