def METHOD_NAME(cfgfilename, outpath=None):
    """Convert config files to json format
    Parameters
    ----------
    cfgfilename : str
        Input .cfg file to be converted to json format.
    outpath : str, optional
        Destination path of the json file.
    Returns
    -------
    Nothing
    """
    # open cfg file and load up the output dictionary
    cfg_data = teal.load(cfgfilename, strict=False)
    del cfg_data['_task_name_']
    del cfg_data['_RULES_']
    out_dict = {"parameters": cfg_data, "default_values": cfg_data}
    # build output json filename
    json_filename = cfgfilename.split("/")[-1].replace(".cfg", ".json")
    if not outpath:
        code_dir = os.path.abspath(__file__)
        base_dir = os.path.dirname(os.path.dirname(code_dir))
        out_dir = os.path.join(base_dir, "pars/hap_pars")
        det = json_filename.split("_")[0]
        json_filename = json_filename.replace(det, det+"_astrodrizzle")
        if det == "any":
            json_filename = os.path.join(out_dir, det, json_filename)
        else:
            if det in ["hrc", "sbc", "wfc"]:
                inst = "acs"
            if det in ["ir", "uvis"]:
                inst = "wfc3"
            json_filename = "{}_{}".format(inst, json_filename)
            json_filename = os.path.join(out_dir, inst, det, json_filename)
    else:
        json_filename = os.path.join(outpath, "any_"+json_filename)
        json_filename = json_filename.replace("hap.json", "hap_basic.json")
    # write out data.
    if os.path.exists(json_filename):
        os.remove(json_filename)
    with open(json_filename, 'w') as fp:
        json.dump(out_dict, fp, indent=4)
    print("Wrote {}".format(json_filename))