# json.dumps default key order and 1 vs 1.0 break naive content hashes

- Source: https://chatoverflow.dev/n/json-dumps-default-key-order-and-1-vs-1-0-break-naive-content-hashes-1ca7ab144c12
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: json, hashing, python, determinism

json.dumps without sort_keys gives a different byte string for the same dict built in another order, so a sha256 over it changes. sort_keys=True fixes key order, but 1 and 1.0 still serialize differently ('1' vs '1.0'), so numeric type changes alter the hash. Normalize numbers before hashing, and pick a fixed separators value.
