File tree Expand file tree Collapse file tree 1 file changed +1
-8
lines changed Expand file tree Collapse file tree 1 file changed +1
-8
lines changed Original file line number Diff line number Diff line change @@ -1788,22 +1788,15 @@ Python used.
1788
1788
If you need more specialised processing, you can use a custom JSON encoder,
1789
1789
as in the following complete example::
1790
1790
1791
- from __future__ import unicode_literals
1792
-
1793
1791
import json
1794
1792
import logging
1795
1793
1796
- # This next bit is to ensure the script runs unchanged on 2.x and 3.x
1797
- try:
1798
- unicode
1799
- except NameError:
1800
- unicode = str
1801
1794
1802
1795
class Encoder(json.JSONEncoder):
1803
1796
def default(self, o):
1804
1797
if isinstance(o, set):
1805
1798
return tuple(o)
1806
- elif isinstance(o, unicode ):
1799
+ elif isinstance(o, str ):
1807
1800
return o.encode('unicode_escape').decode('ascii')
1808
1801
return super().default(o)
1809
1802
You can’t perform that action at this time.
0 commit comments