This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petri.lehtinen
Recipients docs@python, ezio.melotti, petri.lehtinen, rhettinger, socketpair, terry.reedy
Date 2012-08-27.05:00:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1346043615.43.0.759302166798.issue13769@psf.upfronthosting.co.za>
In-reply-to
Content
It seems to me that when ensure_ascii is False, the return value will be a unicode instance if and only if there's a unicode object anywhere in the input.

>>> json.dumps({'foo': 'bar'}, ensure_ascii=False)
'{"foo": "bar"}'

>>> json.dumps({'foo': u'bar'}, ensure_ascii=False)
u'{"foo": "bar"}'

>>> json.dumps({'foo': u'äiti'}, ensure_ascii=False)
u'{"foo": "\xe4iti"}'

>>> json.dumps({'foo': u'äiti'.encode('utf-8')}, ensure_ascii=False)
'{"foo": "\xc3\xa4iti"}'

>>> json.dumps({'foo': u'äiti'.encode('utf-16')}, ensure_ascii=False)
'{"foo": "\xff\xfe\xe4\\u0000i\\u0000t\\u0000i\\u0000"}'
History
Date User Action Args
2012-08-27 05:00:15petri.lehtinensetrecipients: + petri.lehtinen, rhettinger, terry.reedy, ezio.melotti, docs@python, socketpair
2012-08-27 05:00:15petri.lehtinensetmessageid: <1346043615.43.0.759302166798.issue13769@psf.upfronthosting.co.za>
2012-08-27 05:00:14petri.lehtinenlinkissue13769 messages
2012-08-27 05:00:14petri.lehtinencreate