Show More
@@ -12,6 +12,7 b'' | |||
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | # stdlib |
|
14 | 14 | import re |
|
15 | import sys | |
|
15 | 16 | import types |
|
16 | 17 | from datetime import datetime |
|
17 | 18 | |
@@ -121,14 +122,17 b' def json_clean(obj):' | |||
|
121 | 122 | """ |
|
122 | 123 | # types that are 'atomic' and ok in json as-is. bool doesn't need to be |
|
123 | 124 | # listed explicitly because bools pass as int instances |
|
124 |
atomic_ok = ( |
|
|
125 | atomic_ok = (unicode, int, float, types.NoneType) | |
|
125 | 126 | |
|
126 | 127 | # containers that we need to convert into lists |
|
127 | 128 | container_to_list = (tuple, set, types.GeneratorType) |
|
128 | 129 | |
|
129 | 130 | if isinstance(obj, atomic_ok): |
|
130 | 131 | return obj |
|
131 | ||
|
132 | ||
|
133 | if isinstance(obj, bytes): | |
|
134 | return obj.decode(sys.getdefaultencoding(), 'replace') | |
|
135 | ||
|
132 | 136 | if isinstance(obj, container_to_list) or ( |
|
133 | 137 | hasattr(obj, '__iter__') and hasattr(obj, 'next')): |
|
134 | 138 | obj = list(obj) |
General Comments 0
You need to be logged in to leave comments.
Login now