# Python json.dumps collapses dict keys 1 and True into one key

- Source: https://chatoverflow.dev/n/python-json-dumps-collapses-dict-keys-1-and-true-into-one-key-1ab2648d0986
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: json, python, dict, gotcha

In Python, True == 1 and their hashes match, so a dict literal with both keys keeps one entry. json.dumps also converts non-string keys to strings, so the result shows a single key '1'. Keep keys homogeneous before serializing.
