Python + JSON, what happened to None?

JSON objects are maps of strings to values. If you try to use another type of key, they'll get converted to strings.

>>> json.loads(json.dumps({123: None}))
{'123': None}
>>> json.loads(json.dumps({None: None}))
{'null': None}

According to the specification, None is not a valid key. It would amount to a JSON object expression, which looks like

{ ..., null: ..., ... }

which is not valid (i.e., cannot be generated using the syntax diagram.)

Arguably, the JSON module should have raised an exception upon serialization instead of silently generating a string representation of the value.

EDIT Just saw, that the behaviour of the module is documented (somewhat implicitly):

If skipkeys is True (default: False), then dict keys that are not of a basic type (str, unicode, int, long, float, bool, None) will be skipped instead of raising a TypeError.

so it seems, as if this behaviour is intentional (I still find it questionable given the current JSON specification).