def write_json(obj, resource=None, path=None):
    """
    Arguments:
      resource: a stream resource object.
    """
    try:
        jsobj = obj.to_jsobj()
    except __HOLE__:
        jsobj = obj
    if path is not None:
        assert resource is None
        resource = streams.FilePathResource(path, encoding=ENCODING_JSON)
    with resource.open_write() as f:
        return call_json(json.dump, jsobj, f)
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/jsonlib.py/write_json