def json_dumps(obj):
    """Dump json with spaces before and after braces and brackets.

    Cannot just find and replace the braces and brackets because the string representation of the object
    may contain braces and brackets in string content.
    """
    if isinstance(obj, dict):
        items = [f'"{k}": {json_dumps(v)}' for k, v in obj.items()]
        return "{ " + ", ".join(items) + " }"
    elif isinstance(obj, list):
        items = [json_dumps(item) for item in obj]
        return "[ " + ", ".join(items) + " ]"
    else:
        return json.dumps(obj)
Dump json with spaces before and after braces and brackets.

    Cannot just find and replace the braces and brackets because the string representation of the object
    may contain braces and brackets in string content.
    
scripts/format_json.py