##// END OF EJS Templates
Fixed simplejson import on python 2.5
marcink -
r2258:8a3a1a59 beta
parent child Browse files
Show More
@@ -81,22 +81,24 b' except ImportError:'
81 _sj = None
81 _sj = None
82
82
83
83
84 # simplejson not found try out regular json module
84 try:
85 import json as _json
85 # simplejson not found try out regular json module
86
86 import json as _json
87
87
88 # extended JSON encoder for json
88 # extended JSON encoder for json
89 class ExtendedEncoder(_json.JSONEncoder):
89 class ExtendedEncoder(_json.JSONEncoder):
90 def default(self, obj):
90 def default(self, obj):
91 try:
91 try:
92 return _obj_dump(obj)
92 return _obj_dump(obj)
93 except NotImplementedError:
93 except NotImplementedError:
94 pass
94 pass
95 return _json.JSONEncoder.default(self, obj)
95 return _json.JSONEncoder.default(self, obj)
96 # monkey-patch JSON encoder to use extended version
96 # monkey-patch JSON encoder to use extended version
97 _json.dumps = functools.partial(_json.dumps, cls=ExtendedEncoder)
97 _json.dumps = functools.partial(_json.dumps, cls=ExtendedEncoder)
98 _json.dump = functools.partial(_json.dump, cls=ExtendedEncoder)
98 _json.dump = functools.partial(_json.dump, cls=ExtendedEncoder)
99 stdlib = _json
99 stdlib = _json
100 except ImportError:
101 _json = None
100
102
101 # set all available json modules
103 # set all available json modules
102 simplejson = _sj
104 simplejson = _sj
General Comments 0
You need to be logged in to leave comments. Login now