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.

classification
Title: Accept UTF-8 encoded bytes as input to json.loads()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: accept bytes in json.loads()
View: 10976
Assigned To: Nosy List: ezio.melotti, ncoghlan, rhettinger, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-08-15 07:20 by ncoghlan, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg272725 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2016-08-15 07:20
In two recent Python 3 porting projects, a key incompatibility I encountered was that "json.loads(data)" on UTF-8 encoded bytes required an explicit decoding step under Python 3, rather than implicitly decoding the data as UTF-8.

Unlike many other wire formats, assuming UTF-8 for binary JSON data is a pretty safe assumption, and there's no type ambiguity here since the output type is still a properly decoded JSON object.

(This RFE has been split out from the larger RFE at #19837, which also covers implicit *encoding* to UTF-8, which is a more questionable idea)
msg272728 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-08-15 07:29
This looks as a duplicate of issue10976.

See also issue17909 (which covers not just UTF-8, but UTF-16 and UTF-32, in conforming with RFC 4627).
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71952
2016-08-17 12:36:03berker.peksagsetstage: needs patch -> resolved
2016-08-17 12:20:36vstinnersetstatus: open -> closed
superseder: accept bytes in json.loads()
resolution: duplicate
2016-08-15 07:29:13serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg272728
2016-08-15 07:20:28ncoghlancreate