Serialize ``obj`` as a JSON formatted stream to ``fp`` (a ``.write()``-supporting file-like object). If ``skipkeys`` is true then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``Ty
(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
encoding='utf-8', default=None, use_decimal=True,
namedtuple_as_object=True, tuple_as_array=True,
**kw)
| 141 | ) |
| 142 | |
| 143 | def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, |
| 144 | allow_nan=True, cls=None, indent=None, separators=None, |
| 145 | encoding='utf-8', default=None, use_decimal=True, |
| 146 | namedtuple_as_object=True, tuple_as_array=True, |
| 147 | **kw): |
| 148 | """Serialize ``obj`` as a JSON formatted stream to ``fp`` (a |
| 149 | ``.write()``-supporting file-like object). |
| 150 | |
| 151 | If ``skipkeys`` is true then ``dict`` keys that are not basic types |
| 152 | (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) |
| 153 | will be skipped instead of raising a ``TypeError``. |
| 154 | |
| 155 | If ``ensure_ascii`` is false, then the some chunks written to ``fp`` |
| 156 | may be ``unicode`` instances, subject to normal Python ``str`` to |
| 157 | ``unicode`` coercion rules. Unless ``fp.write()`` explicitly |
| 158 | understands ``unicode`` (as in ``codecs.getwriter()``) this is likely |
| 159 | to cause an error. |
| 160 | |
| 161 | If ``check_circular`` is false, then the circular reference check |
| 162 | for container types will be skipped and a circular reference will |
| 163 | result in an ``OverflowError`` (or worse). |
| 164 | |
| 165 | If ``allow_nan`` is false, then it will be a ``ValueError`` to |
| 166 | serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) |
| 167 | in strict compliance of the JSON specification, instead of using the |
| 168 | JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). |
| 169 | |
| 170 | If *indent* is a string, then JSON array elements and object members |
| 171 | will be pretty-printed with a newline followed by that string repeated |
| 172 | for each level of nesting. ``None`` (the default) selects the most compact |
| 173 | representation without any newlines. For backwards compatibility with |
| 174 | versions of simplejson earlier than 2.1.0, an integer is also accepted |
| 175 | and is converted to a string with that many spaces. |
| 176 | |
| 177 | If ``separators`` is an ``(item_separator, dict_separator)`` tuple |
| 178 | then it will be used instead of the default ``(', ', ': ')`` separators. |
| 179 | ``(',', ':')`` is the most compact JSON representation. |
| 180 | |
| 181 | ``encoding`` is the character encoding for str instances, default is UTF-8. |
| 182 | |
| 183 | ``default(obj)`` is a function that should return a serializable version |
| 184 | of obj or raise TypeError. The default simply raises TypeError. |
| 185 | |
| 186 | If *use_decimal* is true (default: ``True``) then decimal.Decimal |
| 187 | will be natively serialized to JSON with full precision. |
| 188 | |
| 189 | If *namedtuple_as_object* is true (default: ``True``), |
| 190 | :class:`tuple` subclasses with ``_asdict()`` methods will be encoded |
| 191 | as JSON objects. |
| 192 | |
| 193 | If *tuple_as_array* is true (default: ``True``), |
| 194 | :class:`tuple` (and subclasses) will be encoded as JSON arrays. |
| 195 | |
| 196 | To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the |
| 197 | ``.default()`` method to serialize additional types), specify it with |
| 198 | the ``cls`` kwarg. |
| 199 | |
| 200 | """ |
nothing calls this directly
no test coverage detected