How do you handle JSON diffs when arrays get reordered?

One thing I kept running into while building JSON Semantic Diff is that comparing JSON arrays by index breaks down pretty quickly.

If the same objects appear in a different order, a small change can suddenly look like dozens of modifications.

I ended up treating it as an identity problem first: which object on the left corresponds to which object on the right? This semantic diff tool tries to infer that from the data, and falls back when it’s ambiguous.

Curious how others handle this today - do you use positional diffs, require a known key like id, ignore array order entirely, or use something else?

7 views

Add a comment

Replies

Be the first to comment