Skip to content

Request for adding a block remove operation for arrays #9

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

Closed
joeltucci opened this issue Mar 24, 2014 · 2 comments
Closed

Request for adding a block remove operation for arrays #9

joeltucci opened this issue Mar 24, 2014 · 2 comments

Comments

@joeltucci
Copy link
Contributor

Currently operations to remove elements in an array are hard to read/write by hand. You either need to list the indexes you want to delete in reverse order or recalculate the indices on the fly, since the operations are applied in a stream and each operation is dependent on the previous(for instance deleting the first 2 elements requires 2 /0's). I would like to propose a block_remove operation that takes an array of indexes(all corresponding to the same position in the original array) and deletes them all at once. This could not only make the resulting diffs more compact, it could also help people who create them by hand.

I have created an example implementation here: joeltucci@341eb02

I didn't want to do this as a pull request since it may need to be significantly reworked, but if possible I would like to see this feature implemented.

Let me know if you have any questions/issues.

@fge
Copy link
Collaborator

fge commented Mar 24, 2014

OK well, the first issue I have is the diff code... While I have started working on it in order to understand it I am still not at ease with it, and I think it needs to be reworked. And it's been months since I've been touching it...

Apart from that I don't like the use of -, since it is meant as a special reference token for additions/removals as defined by RFC 6902 (the last element of an array -- but I think you know that already). If such an operation is created, I'd rather the path point to the array itself.

Finally, well, this goes outside the scope of RFC 6902 ;)

Which kind of calls for a v2; I am not against such an operation being added, far from it, but this would be yet another patch class. Ideally JsonPatch would be made abstract, or even an interface, and one would choose between merge patch, rf6902 or an augmented rfc6902 with this operation included. And of course, there's the diff code...

@joeltucci
Copy link
Contributor Author

Oops, I hadn't even thought about the RFC, sorry about that. I will go ahead and close this request but keep the code hanging around on my fork in case it ever comes in handy. Keep up the good work!

BartekGravity referenced this issue in gravity9-tech/json-patch-path Jun 20, 2023
#787 JsonPath parsing - added throws to java doc
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

No branches or pull requests

2 participants