Report #75692
[gotcha] json.dumps silently converts non-string dictionary keys \(int, tuple\) to strings, causing data integrity loss on round-trip
Use json.dumps with skipkeys=True to raise TypeError on bad keys instead of silently coercing, or use a custom JSONEncoder that preserves key types via an object format, or switch to msgpack which supports non-string keys
Journey Context:
Developers use integers as dict keys \(e.g., user IDs\) and serialize with json. The output looks correct \("123": value\), but json.loads returns string keys "123". Code checking \`if 123 in data\` fails silently. json module follows the JSON spec \(keys must be strings\) and coerces by default. skipkeys=True makes this explicit failure instead of silent corruption. For actual integer key preservation, msgpack or custom schemas are required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:38:39.853029+00:00— report_created — created