-
Notifications
You must be signed in to change notification settings - Fork 0
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
Indexed based array is too limited #12
Comments
+1 for this. This restriction makes JSON Patch simple to implement, but also restricts it to very simple cases. A more sophisticated JSON patch that allowed you to specify a selection criteria for remove and replace (particularly) would allow JSON Patch to be used for a more robust set of use cases, but would significantly increase the complexity. Also, to my knowledge, there's no candidate query for json with a standards track? |
I agree, {
"items": [ "a", "b", "c" ]
} this patch should remove an item by value: { "op": "remove", "path": "/items/-", "value": "b" } to result in: {
"items": [ "a", "c" ]
} See #18. |
+1. The ability to update or remove an element based on its property or wider selection criteria could be very useful. |
+1. this would make my logic more simple. For now, I'm using the test operator as a safety check. |
While navigating to the removal location, you may need to traverse more than one collection from which you need to select an element based on its property's value. The syntax proposed by @jsumners won't work in this more general case, since it splits the selection criteria into Expressing each such traversal in the path as So in @jsumners's simple example, the identifying property would be named "id" instead of "name". And the remove operation would be:
@heruan Your proposal only addresses collections of scalar values. What about collections of complex types as in @jsumners's example? |
As I wrote in this comment:
|
Given the documents:
And:
I want to be able to write a patch:
This is useful when there is no guarantee that the array will always be in the same order, despite being guaranteed to have the same elements.
As JSON Patch currently works, I'm just going to re-factor my array into a hash. But it'd be nice to have this ability in the future.
The text was updated successfully, but these errors were encountered: