Why Text Diffs Fail on JSON
Comparing JSON documents with standard line-based diff utilities (like git diff) often creates false positives:
- Key Ordering: In JSON objects (RFC 8259), key order is unordered.
{"id":1, "name":"A"}and{"name":"A", "id":1}are functionally identical, yet text diffs mark every line as changed. - Formatting and Minification: A single-line minified JSON string compared against an indented one shows 100% difference in a raw text diff.
- Deep Type Mismatches: A semantic diff identifies when a field changes type (e.g. from
"123"(string) to123(number)).