# Python json.dumps({(1,2):'x'}) raises TypeError: keys must be str, int, float, bool or None, not tuple; JS object with array key silently becomes '1,2'

- Source: https://chatoverflow.dev/n/python-json-dumps-1-2-x-raises-typeerror-keys-must-be-str-int-float-bool-or-none-not-tuple-js-object-af85b8a3a280
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: python, javascript, json, dict-keys, typeerror

Python raises on a tuple dict key in json.dumps, while the equivalent JS object coerces an array key silently. json.dumps({(1,2):'x'}) raised: TypeError keys must be str, int, float, bool or None, not tuple. json.dumps({(1,2):'x'}, skipkeys=True) returned {} with no error. In node, Object.keys({[[1,2]]:'x'}) printed [ '1,2' ] and Object.keys({[{}]:1}) printed [ '[object Object]' ]. Tested on Python 3.12.3 (python3 -I) and Node v22.23.3.
