Hacker News new | past | comments | ask | show | jobs | submit | zachromorp's comments login

Hello! I sometimes have big json files to diff. Its content is a big array with complex object inside. The problem I have with all the diff tools I tried (this one included) is that it can't detect if element is missing. When that happens, it computes a very long diff where it could have just said "element is missing at index N". Are you aware of a tool without such caveat ? Thanks


> When that happens, it computes a very long diff where it could have just said "element is missing at index N".

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)".


I'm probably missing something obvious, but diff seems to be handling this just fine?

    # 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"
       }
     ]


Yeah that works. But I also wanted the ability to produce JSON Patch and JSON Merge Patch formats. And to support set semantics, identifying objects by specified keys. And it works on YAML too.


There is a diff functionality which I have provided in unify-jdocs that I think does exactly what you are looking for. You can get the details here -> https://github.com/americanexpress/unify-jdocs. At present it is only for Java. And if you do take a look, please feel free to give feedback - thanks.


IIRC DeepDiff does something like this:

https://github.com/seperman/deepdiff


I often encounter Clojure Chinese users (at least Chinese sounding names, don't know about their nationality). I wonder if Clojure is a thing in China ?


no. But because of the population, even 0.0001% of developers using it, it still has an observable impact on the community.


This comment doesn't pass my Turing test


?


they what???? That sounds like legal racket to me. US prison industry is disgusting.


I will fav this post, so your list will have a chance to be recursively reachable.


Was just thinking this as I liked it.


Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: