import json


def make_json_writer(func, *args, **kwargs):
    """
    Return a function that receives a file-like object and writes the return
    value of func(*args, **kwargs) as JSON to it.
    """

    def writer(f):
        json.dump(func(*args, **kwargs), f, indent=1, ensure_ascii=False)

    return writer