-
Notifications
You must be signed in to change notification settings - Fork 161
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
Implement conversion to JSON Patch format #15
Comments
An implementation of json patch conversion is available as
However I'm not sure what the correct way is to insert multiple values before the same index. The json patch spec seems to be a bit underspecified, could look at other tools to find what they do. |
Great work going on, and on all the other PRs/Issues! I just pulled, and will check it out!
I don't think it's possible, explicitly, and would just require multiple import jsonpatch
import json
a = [1,2,3]
b = [1,2,"orange", "blue", 3]
patch = jsonpatch.make_patch(a, b)
patch.patch [
{
"value": "orange",
"path": "/2",
"op": "add"
},
{
"value": "blue",
"path": "/3",
"op": "add"
}
] Verbose? Sure. But in its verbosity, it requires a far simpler mental model... we shall see if i am more effective building things on this than on straight up dime diff format! |
It's not the verbosity I have problems with, it's what the index in the path refers to. The path /3 here refers to index 3 of the intermediate json object that results from applying the first operation. In other words indices in jsonpatch paths are moving targets... I don't agree that this is a simpler mental model :) In nbdime, the indices in the diff refer to positions in the base object, and this means what you get from the current implementation of to_json_patch in nbdime is garbage, as the indices will need to be updated. |
Really, I don't understand the utility of this model... If you want to see which cells have been modified, which lines have been modified, etc., then the indices in the nbdime diff will be what you want. The indices in the jsonpatch paths are can only be interpreted by going through the patch process. But thanks for the input! |
I'm getting my head around it right now!
Again, recall my user story:
Hopefully i'll have a |
I believe to_json_patch is now working, however the unit test is extremely short! |
As mentioned here:
jupyter/enhancement-proposals#8 (comment)
JSON Patch is a standardized format for representing patches to json documents. We should at least support converting to it, if not adapting it internally as well (it's a bit more verbose).
The text was updated successfully, but these errors were encountered: