Show More
@@ -230,15 +230,11 b' def json(obj):' | |||
|
230 | 230 | elif isinstance(obj, str): |
|
231 | 231 | return '"%s"' % encoding.jsonescape(obj, paranoid=True) |
|
232 | 232 | elif util.safehasattr(obj, 'keys'): |
|
233 | out = [] | |
|
234 |
for k, v in sorted(obj.iteritems()) |
|
|
235 | s = '%s: %s' % (json(k), json(v)) | |
|
236 | out.append(s) | |
|
233 | out = ['%s: %s' % (json(k), json(v)) | |
|
234 | for k, v in sorted(obj.iteritems())] | |
|
237 | 235 | return '{' + ', '.join(out) + '}' |
|
238 | 236 | elif util.safehasattr(obj, '__iter__'): |
|
239 | out = [] | |
|
240 | for i in obj: | |
|
241 | out.append(json(i)) | |
|
237 | out = [json(i) for i in obj] | |
|
242 | 238 | return '[' + ', '.join(out) + ']' |
|
243 | 239 | else: |
|
244 | 240 | raise TypeError('cannot encode type %s' % obj.__class__.__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now