Skip to content

json_wrapper

Utility functions for somesy.

json_dump_wrapper

json_dump_wrapper(wrapped, instance, args, kwargs)

Wrap json.dump to write non-ascii characters with default indentation.

Source code in src/somesy/json_wrapper.py
 7
 8
 9
10
11
12
13
14
@wrapt.decorator
def json_dump_wrapper(wrapped, instance, args, kwargs):
    """Wrap json.dump to write non-ascii characters with default indentation."""
    # Ensure ensure_ascii is set to False
    kwargs["ensure_ascii"] = False
    # set indent to 2 if not set
    kwargs["indent"] = kwargs.get("indent", 2)
    return wrapped(*args, **kwargs)