def METHOD_NAME(data, filename, pretty=False):
    path = Path(filename).parent
    path.mkdir(parents=True, exist_ok=True)
    json_string = _format_json(data, pretty)
    with open(filename, 'wt', newline='\n', encoding='utf-8') as f:
        f.write(json_string)