josephburnett / jd

JSON diff and patch
MIT License
1.62k stars 48 forks source link

WIP: Format json #5

Closed np closed 2 years ago

np commented 6 years ago

These commits add a -f flag to specify the format for the patch. The current format is named native and JSON is supported using -f=json.

While encoding patches works, decoding them does not work yet.

Here is the error, I'm getting:

json: cannot unmarshal string into Go struct field DiffElement.old of type jd.JsonNode

With this patch:

[{"path":["foo"],"old":["bar"],"new":["baz"]}]

Potentially we could tell the unmarshaller to call NewJsonNode.

josephburnett commented 2 years ago

The -f flag is there now and supports three formats, “jd” “merge” and “patch”.