Skip to content

Instantly share code, notes, and snippets.

@PenutChen
PenutChen / CompactJSONEncoder.py
Last active September 8, 2022 04:05 — forked from jannismain/CompactJSONEncoder.py
A JSON Encoder in Python, that puts small lists on single lines.
import json
from typing import Union
class CompactJSONEncoder(json.JSONEncoder):
"""A JSON Encoder that puts small containers on single lines."""
CONTAINER_TYPES = (list, tuple, dict)
"""Container datatypes include primitives or other containers."""