Skip to content

Instantly share code, notes, and snippets.

@jannismain
jannismain / CompactJSONEncoder.py
Last active September 25, 2024 10:23
A JSON Encoder in Python, that puts small lists on single lines.
#!/usr/bin/env python3
from __future__ import annotations
import json
class CompactJSONEncoder(json.JSONEncoder):
"""A JSON Encoder that puts small containers on single lines."""
CONTAINER_TYPES = (list, tuple, dict)