-
Notifications
You must be signed in to change notification settings - Fork 831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON API / JSON-LD integration #587
Comments
We have discussed using prefixes such as My suggestion is to explore hybrid approaches in (non-additive) extensions. |
As I was thinking tonight about extensions, I wanted to mock up what a JSON-LD–annotated version of a JSON-API resource object would look like. Below is what I came up with. I'm leaving it here for reference, in case it helps other implementors and/or our efforts at interoperability. Others can comment here too if they figure out a simpler way to do it.
Note that I'm using the |
Seems like the most reasonable approach. The "links" objects would need "self" keys as well, right? The one concern I have is naming collisions between the jsonapi keywords and possible schema-defined terms. For example, if someone is trying to represent data that requires a "links" term and attempts to use a context mapping rather than an absolute IRI, they will overwrite the jsonapi "links" data. |
Sure, the
Yes, this is a risk/inconvenience. It can always be solved by moving the context closer to the data, but it might be a bit of a pain. Not sure there's anything to do about it, though. |
This seems like a great discussion for http://discuss.jsonapi.org. There is nothing actionable we can do about this here now, so I'm going to give this a close. Thanks guys! |
Noting for #794. |
@tkellen ... I'd love to follow any conversation that happened about this somewhere else. Does anyone else have any resources on how this has evolved? |
I've been looking over both specifications, and I can see two approaches for apps wishing to use both:
LD over API
The advantage is that JSON API wraps the data and JSON-LD formats the data, which seems in line with the intentions of both specs. The challenge is that the "data" object is required to have an "id" and "type" attribute, which is not part of the JSON-LD spec. It's workable but very inconvenient to use both the JSON API type/id and the JSON-LD @type/@id. It would be preferable to change JSON API to use JSON-LD-style @type/@id names and syntax.
API over LD
The advantage is that JSON-LD is general enough that JSON API is a valid subset (if the root object is augmented with an appropriate context/schema). The disadvantage is that because none of the JSON-API data includes @type or @id keys, they would need to be defined in the context. There would be a lot of duplication because each context would have to include definitions for the standard JSON API type/id/self fields.
Conclusion
It seems to me that the LD over API approach would be preferable, but that would require changes to JSON API that aren't backwards compatible (renaming type/self/id fields). I'd be happy to help make these changes.
The text was updated successfully, but these errors were encountered: