[Python-porting] json encoding

Armin Ronacher armin.ronacher at active-4.com
Sat Jun 20 01:27:14 CEST 2015


Hi,

On 20/06/2015 01:18, R. David Murray wrote:
> I haven't done any code that used json and needed to run on both python2
> and python3, so I can't tell you if there is an easier way.  But in general
> you do have to jump through some hoops when supporting both dialects.
There definitely is.  Look at flask.json for a wrapper around the 
stdlib's JSON module which supports bytes in more places.  This also is 
necessary to make code work with both json and simplejson which have 
different behavior for unicode support.

For the curious: 
https://github.com/mitsuhiko/flask/blob/master/flask/json.py


Regards,
Armin


More information about the Python-porting mailing list