josephburnett / jd

JSON diff and patch
MIT License
1.86k stars 51 forks source link

Support JSON Patch format #1

Closed josephburnett closed 2 years ago

josephburnett commented 7 years ago

Add support for rendering and reading diffs in JSON Patch format: https://tools.ietf.org/html/draft-ietf-appsawg-json-patch-10

jpsim commented 7 years ago

This would be 👌

np commented 6 years ago

A first step would be to emit objects of the form: {path: PATH, old: OLD, new: NEW} (instead of @ PATH\n- OLD\n+ NEW")

mandric commented 3 years ago

Is there any support for this that is undocumented? Is there another tool that does support json-patch style patches? Surprised this issue (#1) hasn't been worked on? Is it in the works or has anyone started a branch? ;-)

josephburnett commented 2 years ago

Added -f flag to choose output format (https://github.com/josephburnett/jd/commit/52a000e20c09d5019947a7e2a9d29f20817d7aea). A value of patch will output an RFC 6901 JSON Patch. Removal is done with test and remove ops because jd diffs are strict and expect a value to be present when removed.

josephburnett commented 2 years ago

I've closed this because I don't really intend on reading JSON Patch format diffs. I think that writing them is enough. If you need it, please open a feature request issue.

josephburnett commented 2 years ago

Actually I want to add support for reading back the JSON Patch's that I write so I can add E2E tests and verify round-tripping. So I'm opening this again until the E2E tests for JSON Patch are added.

josephburnett commented 2 years ago

Okay, I've added E2E tests. And a translate function to turn jd diffs into JSON Patch format. Here is an example of how to use this with kubectl: https://github.com/josephburnett/jd#see-what-changes-in-a-kuberentes-deployment