[issue6566] json.dumps converts None to "null" (not null)

Sridhar Ratnakumar report at bugs.python.org
Fri Jul 24 23:07:58 CEST 2009


New submission from Sridhar Ratnakumar <sridharr at activestate.com>:

In [2]: json.dumps({'a': 1, 'b': {'c': 3, None: 5}})
Out[2]: '{"a": 1, "b": {"c": 3, "null": 5}}'

In [3]: j = json.dumps({'a': 1, 'b': {'c': 3, None: 5}})

In [4]: json.loads(j)
Out[4]: {u'a': 1, u'b': {u'c': 3, u'null': 5}}

I was surprised to note that None was converted to "null" instead of 
null. This happens only in dicts and not, for example, lists:

In [5]: json.dumps([None, 1, "a"])
Out[5]: '[null, 1, "a"]'

----------
components: Library (Lib)
messages: 90896
nosy: srid
severity: normal
status: open
title: json.dumps converts None to "null" (not null)
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6566>
_______________________________________


More information about the Python-bugs-list mailing list