Skip to content

change link removal example to be "set-like" rather than "array-like" #99

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

Merged
merged 1 commit into from
May 27, 2013

Conversation

gabrielgrant
Copy link
Contributor

The example of "removing comment 5 from this photo" uses "/photos/0/links/comments/1" as it's path. That references the array index of the comment in it's collection, treating it like an array, however the surrounding text explicitly states that "to-many relationships have set-like behavior in JSON API"

This set-like behavior isn't really defined (I don't see it mentioned anywhere in the JSON Patch RFC ), but it seems like it should mean "values are returned as an array, but the items in that array should be treated as though they were object keys with ignorable values". Basically, the order of that array should be explicitly ignored, and references should be by ID rather that array index.

This would to imply that the example should be "/photos/0/links/comments/5" (by ID -- it's a set, not by array index)

steveklabnik added a commit that referenced this pull request May 27, 2013
change link removal example to be "set-like" rather than "array-like"
@steveklabnik steveklabnik merged commit fb72538 into json-api:gh-pages May 27, 2013
@steveklabnik
Copy link
Contributor

Thank you ! This is more motivation for me to change the way we discuss JSON PATCH in this spec; we shouldn't need to re-iterate it's rules here. Haven't gotten to it yet.

@guillec
Copy link
Contributor

guillec commented May 27, 2013

The difficulty here is more JSON Pointer which is what JSON Patch uses for the operation path.
From my understanding the only way to access a object in a array is by specifying the index in the array.

@gabrielgrant gabrielgrant deleted the patch-1 branch May 27, 2013 17:00
@gabrielgrant gabrielgrant restored the patch-1 branch May 27, 2013 17:00
@gabrielgrant gabrielgrant deleted the patch-1 branch May 27, 2013 17:10
@gabrielgrant
Copy link
Contributor Author

@guillec I agree this is a limitation, though I'm not sure that either spec is exactly "at fault": to be able to reference array elements by value, JSON Pointer would have to evolve more into a query API, which seems somewhat outside it's intended scope.

The JSON patch spec could define this "set-like behavior", but it doesn't, so JSON API should clarify it (hence #100 ). As I mentioned, it seems "set-like" objects are represented as an array when read and added to (only via appending), but treated more as an object (with the array elements as both key names and values) when updated.

I see you're running up against somewhat similar limitations with #91 . Again there, I'm not sure that sticking strictly within the JSON Patch/Pointer specs is the best approach.

@guillec
Copy link
Contributor

guillec commented May 27, 2013

Yup it all makes sense, as I was editing the paths on #91 I was following the JSON Patch/Pointer specs. I agree, strictly sticking within the JSON Patch/Pointer specs might not be the best solution here.

@steveklabnik
Copy link
Contributor

If the JSON PATCH spec can't handle something, it's a bug in that spec. We shouldn't be extending another RFC unless we absolutely have to.

@steveklabnik
Copy link
Contributor

... specifically because we don't have jurisdiction to. If you send a request with the application/patch+json (or whatever, I think that's it, still haven't memorized it) type, then you follow its rules, not 'our' rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
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