I can’t help thinking that the topic of “composite” keys is of some potential relevance here.
To identify a single resource, the spec wants you to use a unique ID to do so. Building that ID up as a composite of other IDs is certainly possible but can run into namespace issues or allowable character issues.
Have a look at some of these for potential inspiration:
I have been working with JSON API for the past 9 months and have been under the assumption after reading the specification several times that Resources can be composed of other Resources when the relationship is composition or whole/part type of containment between Resources. Not that the specification directly said this but never directly said it could not and composition is so fundamental I just assumed composition was legal.
Let me give you a real world example: Here at work is an example JS…
Hello
I´m trying to define a standard for my API. Every resource I have right now, comes from a SQL Server Database. And most of them, are tables with a composite primary key.
Every resource has a href property pointing to itself, but i also need to complete an Id property to be able to identify it.
As they have composite keys, I thougth of setting the id property with the json value of the key object, for example:
Lets say just a silly example just to be more clear of a city resource:
City…
@brainwipe first of all thank you for the suggestion to model the problem with relations.
However, this is not an answer to the original problem (the question wasn’t properly defined, sorry)
Let me clarify it:
Some entities have a natural unique key (https://en.wikipedia.org/wiki/Natural_key ) coming from business
Example: consider Product that is defined by EAN (European Article Number). In this case EAN is used as “id” attribute as it uniquely identifies a product (at least in Europe).
…