-
Notifications
You must be signed in to change notification settings - Fork 890
Description
There is a strong possibility of a name conflict within the key space of a resource with the four reserved keys, [id
, type
, href
, links
]. I'd like to float the idea of prefixing these keys with an underscore (or other character). Thus we would have the reserved keys of [_id
, _type
, _href
, _links
].
The primary benefit is that it opens up the possibility of using a key with one of the currently reserved key names. I think it is quite likely for some existing datasets to be using the href
and type
keys and this will save developers the need to rename these existing keys. A secondary (and minor) benefit is that it's easy to pick out the special keys visually.
The only downside I see is the adding of an extra character to each key, but with compression that is mostly a non issue. It's also possible there could still be conflicts, but its probability is probably a couple of orders of magnitude less.
An example:
{
"posts": {
"id": "1",
"title": "Rails is Omakase",
"post_href": "/rails_is_omakase"
}
}
would become:
{
"posts": {
"_id": "1",
"title": "Rails is Omakase",
"href": "/rails_is_omakase"
}
}
or
{
"posts": {
"_id": "1",
"_type": "posts",
"_href": "http://example.com/posts/1",
"title": "Rails is Omakase",
"href": "/rails_is_omakase",
"_links": {
"author": "9",
"comments": [ "4", "5" ]
}
}
}
Thoughts?