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``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``.
(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=False, cls=None, indent=None, separators=None,
encoding='utf-8', default=None, use_decimal=True,
namedtuple_as_object=True, tuple_as_array=True,
bigint_as_string=False, sort_keys=False, item_sort_key=None,
for_json=False, ignore_nan=False, int_as_string_bitcount=None,
iterable_as_array=False, **kw)
| 153 | _default_encoder = JSONEncoder() |
| 154 | |
| 155 | def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, |
| 156 | allow_nan=False, cls=None, indent=None, separators=None, |
| 157 | encoding='utf-8', default=None, use_decimal=True, |
| 158 | namedtuple_as_object=True, tuple_as_array=True, |
| 159 | bigint_as_string=False, sort_keys=False, item_sort_key=None, |
| 160 | for_json=False, ignore_nan=False, int_as_string_bitcount=None, |
| 161 | iterable_as_array=False, **kw): |
| 162 | """Serialize ``obj`` as a JSON formatted stream to ``fp`` (a |
| 163 | ``.write()``-supporting file-like object). |
| 164 | |
| 165 | If *skipkeys* is true then ``dict`` keys that are not basic types |
| 166 | (``str``, ``int``, ``long``, ``float``, ``bool``, ``None``) |
| 167 | will be skipped instead of raising a ``TypeError``. |
| 168 | |
| 169 | If *ensure_ascii* is false (default: ``True``), then the output may |
| 170 | contain non-ASCII characters, so long as they do not need to be escaped |
| 171 | by JSON. When it is true, all non-ASCII characters are escaped. |
| 172 | |
| 173 | If *allow_nan* is true (default: ``False``), then out of range ``float`` |
| 174 | values (``nan``, ``inf``, ``-inf``) will be serialized to |
| 175 | their JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``) |
| 176 | instead of raising a ValueError. See |
| 177 | *ignore_nan* for ECMA-262 compliant behavior. |
| 178 | |
| 179 | If *indent* is a string, then JSON array elements and object members |
| 180 | will be pretty-printed with a newline followed by that string repeated |
| 181 | for each level of nesting. ``None`` (the default) selects the most compact |
| 182 | representation without any newlines. |
| 183 | |
| 184 | If specified, *separators* should be an |
| 185 | ``(item_separator, key_separator)`` tuple. The default is ``(', ', ': ')`` |
| 186 | if *indent* is ``None`` and ``(',', ': ')`` otherwise. To get the most |
| 187 | compact JSON representation, you should specify ``(',', ':')`` to eliminate |
| 188 | whitespace. |
| 189 | |
| 190 | *encoding* is the character encoding for str instances, default is UTF-8. |
| 191 | |
| 192 | *default(obj)* is a function that should return a serializable version |
| 193 | of obj or raise ``TypeError``. The default simply raises ``TypeError``. |
| 194 | |
| 195 | If *use_decimal* is true (default: ``True``) then decimal.Decimal |
| 196 | will be natively serialized to JSON with full precision. |
| 197 | |
| 198 | If *namedtuple_as_object* is true (default: ``True``), |
| 199 | :class:`tuple` subclasses with ``_asdict()`` methods will be encoded |
| 200 | as JSON objects. |
| 201 | |
| 202 | If *tuple_as_array* is true (default: ``True``), |
| 203 | :class:`tuple` (and subclasses) will be encoded as JSON arrays. |
| 204 | |
| 205 | If *iterable_as_array* is true (default: ``False``), |
| 206 | any object not in the above table that implements ``__iter__()`` |
| 207 | will be encoded as a JSON array. |
| 208 | |
| 209 | If *bigint_as_string* is true (default: ``False``), ints 2**53 and higher |
| 210 | or lower than -2**53 will be encoded as strings. This is to avoid the |
| 211 | rounding that happens in Javascript otherwise. Note that this is still a |
| 212 | lossy operation that will not round-trip correctly and should be used |
nothing calls this directly
no test coverage detected
searching dependent graphs…