You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 line
473 B

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