-
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
Batches from a base path to decrease the amount of text required. #9
Comments
How about a general-purpose [
{ "op": "scope", "path": "/user/0", "value": [
{ "op": "replace", "path": "/email", "value": "[email protected]" },
{ "op": "replace", "path": "/phone", "value": "+64 4 555 5555" },
{ "op": "remove", "path": "/password" }
] },
{ "op": "add", "path": "/hello", "value": ["world"] }
] |
Yes that's a good idea, and you could have scopes within scopes. In this case the paths within the scopes should be relative. The leading / would indicate that they would go back to the root of the object, so they should start with a ./ or nothing, i.e. ./email, ./phone or email, phone, you could theoretically also have ../1/email to modify something outside of the path, in that case modify /user/1/ instead of /user/0/ but that is getting silly. [
{ "op": "scope", "path": "/user/0", "value": [
{ "op": "replace", "path": "email", "value": "[email protected]" },
{ "op": "replace", "path": "phone/office", "value": "+64 4 555 5555" },
{ "op": "remove", "path": "password" }
] },
{ "op": "add", "path": "/hello", "value": ["world"] }
] It's still too much duplicated text and information for my liking. I'm thinking if you are storing millions of patches or sending thousands of patches down the wire, but if you are clever with nested scopes it is much more efficient than having every operation separate. |
I would be against this proposal because I think this is premature optimization. These days it is easy to use some compression algorithm on top of the transport you are using for your JSON patches, which would make deduplicate such repetitions. I would not complicate the PATCH format itself. |
Having the paths in ever operation seems needlessly verbose for batches of updates, so I propose the introduction of batches.
If I had an object:
And I wanted to replace the email and phone items I would need to go:
If I have big objects with lots of changes then that is going to be allot of information to transport, something like:
The text was updated successfully, but these errors were encountered: