The developer can always choose to use a shorted local alias for commonly used tools.
That being said, I wonder if this is much better than difftastic that is more general purpose, but tree-aware? I suppose this one wouldn't care about JSON dictionary key ordering, at least.
- Stacked Git
- Shortened: stgit
- Command: stg
Lots of “stgit: command not found” ensues.
In a way, it is a sort of seo race for tool devs.
> As such, some people may now refer to this directory as meaning 'User System Resources' and not 'user' as was originally intended.
https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/usr.htm...
Yeah, in retrospect I should have given this a longer name. I was going for a natural fit with `jq`. ¯\_(ツ)_/¯
> I wonder if this is much better than difftastic that is more general purpose, but tree-aware?
There are quite a few good tree-aware JSON diff tools out there. But I wanted one that could also be used for patching. I've tried to maintain the invariant that all diffs can be applied as patches without losing anything. And I also wanted better set (and multi-set) semantics, since the ordering of JSON arrays so often isn't important.
It turns JSON to JS syntax. it"s perfect for these tasks.
This uncovered a few edge cases we likely wouldn't have caught otherwise and I'm honestly really happy with that approach!
One thing I would note is that some restructurings with jq increased the quality of the diff by a lot. This is not a criticism of jd, it's just a consequence of me applying some extra domain knowledge that a generic tool could never have.
I would really like to know more about these restructurings. Would you mind dropping me an example here or at https://github.com/josephburnett/jd/issues please? There are somethings I won't do with jd (e.g. generic data transformations) but I do plan to add some more semantic aware metadata with the v2 API.
Also, I'm glad this tool helped you! Made my day to here it :)
That's exactly the problem addressed by this issue: https://github.com/josephburnett/jd/issues/50. And I've created a new v2 format to address this and other usecases. The v2 API will compute the longest common subsequence of two arrays and structure the diff around that (a standard way of producing a minimum diff).
I've just released jd 1.9.1 with the `-v2` flag. Would you mind trying one of your use cases to see if the diff looks any better? I should say something exactly like that "@ (some path) - (some element)".
# diff -u <(echo '[{"a": "b"}, {"c": "d"}, {"e": "f"}]' | jq) <(echo '[{"a": "b"}, {"e": "f"}]' | jq)
--- /dev/fd/63 2024-09-09 16:31:23.376841575 +0200
+++ /dev/fd/62 2024-09-09 16:31:23.376841575 +0200
@@ -3,9 +3,6 @@
"a": "b"
},
{
- "c": "d"
- },
- {
"e": "f"
}
]
[0] https://gist.github.com/Checksum/17c84306f563eca40b353f6ed83...
One feature I’ve yet to see is applying jq query syntax to the jsons before the diff
Will you please add this as a feature request? https://github.com/josephburnett/jd/issues. I would like to hear more about how you would use it.
I've added support to use jd as a Git diff engine: https://github.com/josephburnett/jd?tab=readme-ov-file#use-g.... Can you configure VS Code use a custom command to show diffs?