src/itsdangerous/_json.py
raw| 1 | from __future__ import annotations |
| 2 | |
| 3 | import json as _json |
| 4 | import typing as t |
| 5 | |
| 6 | |
| 7 | class _CompactJSON: |
| 8 | """Wrapper around json module that strips whitespace.""" |
| 9 | |
| 10 | @staticmethod |
| 11 | def loads(payload: str | bytes) -> t.Any: |
| 12 | return _json.loads(payload) |
| 13 | |
| 14 | @staticmethod |
| 15 | def dumps(obj: t.Any, **kwargs: t.Any) -> str: |
| 16 | kwargs.setdefault("ensure_ascii", False) |
| 17 | kwargs.setdefault("separators", (",", ":")) |
| 18 | return _json.dumps(obj, **kwargs) |