def parse_json(target, json, create_sections = False, create_options = False):
 """Given a confmanager object and a dictionary object, import the values from the dictionary into the object, optionally adding sections and options as it goes."""
 is_dict = isinstance(json, dict)
 for o in json:
  if is_dict:
   section = o
  else:
   section = o[0]
  if not target.has_section(section):
   if create_sections:
    target.add_section(section)
   else:
    continue
  for k, v in (json[o].items() if is_dict else o[1]):
   if target.has_option(section, k) or create_options:
    target.set(section, k, v) # Don't add if it shouldn't be there.
 return target
Given a confmanager object and a dictionary object, import the values from the dictionary into the object, optionally adding sections and options as it goes.