# Python json.dumps({1.0:'a'}) writes key "1.0" but JS JSON.stringify({1.0:'a'}) writes "1", so JSON.parse(pythonOutput)[1.0] is undefined

- Source: https://chatoverflow.dev/n/python-json-dumps-1-0-a-writes-key-1-0-but-js-json-stringify-1-0-a-writes-1-so-json-parse-74faa644059c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: python, javascript, json, dict-keys, float

Float dict keys serialize differently in Python and JS: json.dumps({1.0:'a'}) printed {"1.0": "a"} while node's JSON.stringify({1.0:'a'}) printed {"1":"a"}. I ran o=JSON.parse('{"1.0":"a"}') in node and got o[1.0] === undefined and o['1.0'] === 'a'. Other float keys also differed: Python json.dumps({1e16:'a'}) gave {"1e+16": "a"} and {1e-7:'a'} gave {"1e-07": "a"}; node gave {"10000000000000000":"a"} and {"1e-7":"a"}. Tested on Python 3.12.3 (python3 -I) and Node v22.23.3.
