Serialize ``obj`` to a JSON formatted ``str``. 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``. If *ensure_ascii* is false (default: ``True``), then th
(obj, 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)
| 275 | |
| 276 | |
| 277 | def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, |
| 278 | allow_nan=False, cls=None, indent=None, separators=None, |
| 279 | encoding='utf-8', default=None, use_decimal=True, |
| 280 | namedtuple_as_object=True, tuple_as_array=True, |
| 281 | bigint_as_string=False, sort_keys=False, item_sort_key=None, |
| 282 | for_json=False, ignore_nan=False, int_as_string_bitcount=None, |
| 283 | iterable_as_array=False, **kw): |
| 284 | """Serialize ``obj`` to a JSON formatted ``str``. |
| 285 | |
| 286 | If ``skipkeys`` is true then ``dict`` keys that are not basic types |
| 287 | (``str``, ``int``, ``long``, ``float``, ``bool``, ``None``) |
| 288 | will be skipped instead of raising a ``TypeError``. |
| 289 | |
| 290 | If *ensure_ascii* is false (default: ``True``), then the output may |
| 291 | contain non-ASCII characters, so long as they do not need to be escaped |
| 292 | by JSON. When it is true, all non-ASCII characters are escaped. |
| 293 | |
| 294 | If ``check_circular`` is false, then the circular reference check |
| 295 | for container types will be skipped and a circular reference will |
| 296 | result in an ``OverflowError`` (or worse). |
| 297 | |
| 298 | If *allow_nan* is true (default: ``False``), then out of range ``float`` |
| 299 | values (``nan``, ``inf``, ``-inf``) will be serialized to |
| 300 | their JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``) |
| 301 | instead of raising a ValueError. See |
| 302 | *ignore_nan* for ECMA-262 compliant behavior. |
| 303 | |
| 304 | If ``indent`` is a string, then JSON array elements and object members |
| 305 | will be pretty-printed with a newline followed by that string repeated |
| 306 | for each level of nesting. ``None`` (the default) selects the most compact |
| 307 | representation without any newlines. For backwards compatibility with |
| 308 | versions of simplejson earlier than 2.1.0, an integer is also accepted |
| 309 | and is converted to a string with that many spaces. |
| 310 | |
| 311 | If specified, ``separators`` should be an |
| 312 | ``(item_separator, key_separator)`` tuple. The default is ``(', ', ': ')`` |
| 313 | if *indent* is ``None`` and ``(',', ': ')`` otherwise. To get the most |
| 314 | compact JSON representation, you should specify ``(',', ':')`` to eliminate |
| 315 | whitespace. |
| 316 | |
| 317 | ``encoding`` is the character encoding for bytes instances, default is |
| 318 | UTF-8. |
| 319 | |
| 320 | ``default(obj)`` is a function that should return a serializable version |
| 321 | of obj or raise TypeError. The default simply raises TypeError. |
| 322 | |
| 323 | If *use_decimal* is true (default: ``True``) then decimal.Decimal |
| 324 | will be natively serialized to JSON with full precision. |
| 325 | |
| 326 | If *namedtuple_as_object* is true (default: ``True``), |
| 327 | :class:`tuple` subclasses with ``_asdict()`` methods will be encoded |
| 328 | as JSON objects. |
| 329 | |
| 330 | If *tuple_as_array* is true (default: ``True``), |
| 331 | :class:`tuple` (and subclasses) will be encoded as JSON arrays. |
| 332 | |
| 333 | If *iterable_as_array* is true (default: ``False``), |
| 334 | any object not in the above table that implements ``__iter__()`` |
searching dependent graphs…