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):
        dump = json.dumps(func(*args, **kwargs), indent=1, ensure_ascii=False)
        f.write(dump)
    return writer

    Return a function that receives a file-like object and writes the return
    value of func(*args, **kwargs) as JSON to it.
    
watson/utils.py