20 Recursively merging configuration dictionaries. 23 base: Target for merge 24 delta: Dictionary to merge into base 27 for k, dv
in delta.items():
29 if isinstance(dv, dict)
and isinstance(bv, dict):
36 """ Loads an JSON file, ignoring comments 38 Supports a trivial extension to the JSON file format. Allow comments 39 to be embedded within the JSON, requiring that a comment be on an 40 independent line starting with '//' or '#'. 42 NOTE: A file created with these style comments will break strict JSON 43 parsers. This is similar to but lighter-weight than "human json" 44 proposed at https://hjson.org 47 filename (str): path to the commented JSON file 50 obj: decoded Python object 52 with open(filename)
as f:
59 """ Removes comments from a JSON string. 61 Supporting a trivial extension to the JSON format. Allow comments 62 to be embedded within the JSON, requiring that a comment be on an 63 independent line starting with '//' or '#'. 72 commented_json_str (str): a JSON string 75 str: uncommented, legal JSON 77 lines = commented_json_str.splitlines()
81 stripped = line.lstrip()
82 if stripped.startswith(
"//")
or stripped.startswith(
"#"):
84 nocomment.append(line)
86 return " ".join(nocomment)
def uncomment_json(commented_json_str)
def load_commented_json(filename)
def merge_dict(base, delta)