given a start json file file1.json and a final file2.json
how is possible to create a patch that applied to file1.json creates fil2.json
?
Hello fannullone,
To create a patch file, enter the command below into the command line:
diff -u file1.json file2.json > patchfile.patch
In the example above, the diff output will be saved into a file named patchfile.patch.
Once the patch file is created, you can use it to copy the changes to another file. For example, you may want to overwrite file1 with the changes from the updated file2. To do this, you could use syntax like this:
patch file1.json patchfile.patch
There might be some tools to diff JSON that could produce JSON patches. I am not aware of any. You could also probably create a JSON patch (RFC 6902) from the target JSON that completely overwrote the original JSON.
However, without more context, it's difficult to say if this would solve a particular problem. But I can see how it might make some issues worse
Hello fannullone,
To create a patch file, enter the command below into the command line:
diff -u file1.json file2.json > patchfile.patch
In the example above, the diff output will be saved into a file named patchfile.patch.
Once the patch file is created, you can use it to copy the changes to another file. For example, you may want to overwrite file1 with the changes from the updated file2. To do this, you could use syntax like this:
patch file1.json patchfile.patch
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.