Issue 10216: json.loads() on str erroneously returns str (original) (raw)
Issue10216
Created on 2010-10-27 20:41 by barry, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (4) | ||
---|---|---|
msg119732 - (view) | Author: Barry A. Warsaw (barry) * ![]() |
Date: 2010-10-27 20:41 |
json is defined as mapping the JSON string type into unicodes. This works as advertised in Python 2.6 and 3, but in Python 2.7 it returns a str. % python2.6 -c "import json; print json.loads('{\"foo\":\"bar\"}')" {u'foo': u'bar'} % python2.7 -c "import json; print json.loads('{\"foo\":\"bar\"}')" {'foo': 'bar'} Platform tested so far: Ubuntu 10.10 amd64. | ||
msg119733 - (view) | Author: Barry A. Warsaw (barry) * ![]() |
Date: 2010-10-27 20:42 |
BTW, the workaround for Python 2.7 is to pass a unicode to json.loads(). | ||
msg119735 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2010-10-27 20:43 |
Duplicate of . | ||
msg119738 - (view) | Author: Barry A. Warsaw (barry) * ![]() |
Date: 2010-10-27 20:49 |
Yay. I guess I have to submit a tracker bug now because searching for "json unicode" didn't turn up the original bug. ;/ Thanks for duping it __ap__. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:07 | admin | set | github: 54425 |
2010-10-27 20:49:53 | barry | set | messages: + |
2010-10-27 20:43:55 | pitrou | set | status: open -> closednosy: + pitroumessages: + superseder: json.loads() on str should return unicode, not strresolution: duplicate |
2010-10-27 20:42:17 | barry | set | messages: + |
2010-10-27 20:41:16 | barry | create |