Skip to content

Prefix reserved keys in resources #313

@lgebhardt

Description

@lgebhardt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy