You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Accept UTF-8 encoded bytes as input to json.loads() #71952
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 bpo-19837, which also covers implicit *encoding* to UTF-8, which is a more questionable idea)
Activity
ncoghlan commentedon Aug 15, 2016
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 bpo-19837, which also covers implicit *encoding* to UTF-8, which is a more questionable idea)
serhiy-storchaka commentedon Aug 15, 2016
This looks as a duplicate of bpo-10976.
See also bpo-17909 (which covers not just UTF-8, but UTF-16 and UTF-32, in conforming with RFC 4627).