-
Notifications
You must be signed in to change notification settings - Fork 890
Description
I'm writing an application which reads a potentially unknown database and outputs its using json:api. When outputting a resource, the data
key (mostly) just contains the data from the database row. For the json:api format other special keys need to be added like id
, type
, links
, etc. This conflicts when a database table contains such keys as columns. I.e. type
is not uncommon as a table column and could mean something else than the resource type (i.e. table name).
I can imagine several ways to solve this conflict. AFAIK only the last variant is allowed according to the spec, but according to the human eye and sense, is also the most strange one.
{
"data": {
"id": 1,
"type": "foo",
"links": {},
"resource": {
"title": "...",
"type": "...",
"bio": "...",
}
}
}
{
"data": {
"_id": 1,
"_type": "foo",
"_links": {},
"title": "...",
"type": "...",
"bio": "...",
}
}
{
"data": {
"id": 1,
"type": "foo",
"links": {},
},
"meta": {
"data": {
"title": "...",
"type": "...",
"bio": "...",
}
}
}
Is there a common way to solve this problem? Or is json:api not really suited for this kind of usage?