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

2012-03-17 Thread Merlijn van Deen
Merlijn van Deen added the comment: JSON does not have the distinction between bytes and unicode; py2 strings are coerced into unicode. I think it would be better to speak about 'JSON string' or 'JSON string element' if it's JSON and about 'unicode' (2.7) or 'str' (3.x) when speaking about t

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

2012-03-17 Thread Kirubakaran Athmanathan
Kirubakaran Athmanathan added the comment: json.dumps({u'foo':'bar'}) '{"foo": "bar"}' -- ___ Python tracker ___ ___ Python-bugs-list

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

2012-03-17 Thread Kirubakaran Athmanathan
Kirubakaran Athmanathan added the comment: The note added "Keys in key/value pairs of JSON are always of the type str. When a dictionary is converted into JSON, all the keys of the dictionary are coerced to strings." is true for unicode keys too. '{"foo": "bar"}' -- __

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

2012-03-17 Thread Éric Araujo
Éric Araujo added the comment: Shouldn’t the 2.7 docs talk about str and unicode, or maybe basestring, instead of just str? -- nosy: +eric.araujo ___ Python tracker ___

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

2012-03-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 7c818b4cd98a by Senthil Kumaran in branch '2.7': explain json.dumps for non-string keys in dicts. closes issue6566. Patch contributed Kirubakaran Athmanathan http://hg.python.org/cpython/rev/7c818b4cd98a New changeset 613919591a05 by Senthil Kumar

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

2012-03-17 Thread Kirubakaran Athmanathan
Kirubakaran Athmanathan added the comment: Here is the patch that fixes for 3.3 -- Added file: http://bugs.python.org/file24900/6566.3.3.patch ___ Python tracker ___

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

2012-03-17 Thread Kirubakaran Athmanathan
Kirubakaran Athmanathan added the comment: Here is the patch that fixes for 2.7 -- keywords: +patch nosy: +kirubakaran Added file: http://bugs.python.org/file24899/6566.2.7.patch ___ Python tracker

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

2009-07-25 Thread Bob Ippolito
Bob Ippolito added the comment: JP is correct, this is how JSON works. The behavior of coercing keys to strings is often desirable, although I agree it could be confusing if you aren't familiar with the JSON spec. -- components: +Documentation -Library (Lib) _

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

2009-07-24 Thread Sridhar Ratnakumar
Sridhar Ratnakumar added the comment: > JSON dict keys are strings *only*. I might be helpful to point this out (along with other caveats) in the standard library documentation for JSON. An explicit mention of ``loads(dumps(x)) != x for certain structures`` would be nice. I, sir, was genuin

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

2009-07-24 Thread Jean-Paul Calderone
Jean-Paul Calderone added the comment: Notice what it does to other dict keys: >>> simplejson.dumps({1: 1}) '{"1": 1}' In other words, I don't think this is a bug. It's how JSON works. JSON dict keys are strings *only*. -- nosy: +exarkun

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

2009-07-24 Thread Sridhar Ratnakumar
Sridhar Ratnakumar added the comment: Also repros on 3.0/3.1 -- versions: +Python 3.0, Python 3.1 ___ Python tracker ___ ___ Python-bu

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

2009-07-24 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- assignee: -> bob.ippolito nosy: +bob.ippolito status: open -> ___ Python tracker ___ ___ Python-bug

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

2009-07-24 Thread Sridhar Ratnakumar
Sridhar Ratnakumar added the comment: The simplest repro: In [6]: json.dumps({None: 3}) Out[6]: '{"null": 3}' In [7]: json.loads(json.dumps({None: 3})) Out[7]: {u'null': 3} -- ___ Python tracker _

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

2009-07-24 Thread Sridhar Ratnakumar
New submission from Sridhar Ratnakumar : 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