
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,148 Views
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
?
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,113 Views
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.
Overwrite files with changes
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,122 Views
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 1,114 Views
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.
Overwrite files with changes
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