code: def to_json(obj, pretty=False):
    
    sort_keys = False
    indent = None
    separators = (",", ":")
  
    if isinstance(pretty, tuple):
      sort_keys, indent, separators = pretty
    elif pretty is True:
      sort_keys = True
      indent = 2
      separators = (", ", ": ")
  
    return json.dumps(obj, sort_keys=sort_keys, indent=indent, separators=separators,
                      default=json_default)
docs: Converts an object to JSON, using the defaults specified in register_json_default.
  
    :obj: the object to convert to JSON
    :pretty: if True, extra whitespace is added to make the output easier to read