code: def Dump(obj,
           sort_keys = False,
           encoder = None):
    
    # Python 2 json.dumps expects separators as a tuple of bytes, while
    # Python 3 expects them to be a tuple of unicode strings. Pytype
    # is too dumb to infer the result of the if statement that sets
    # _SEPARATORS and complains when running in Python 3 mode.
    text = json.dumps(
        obj,
        indent=2,
        sort_keys=sort_keys,
        ensure_ascii=False,
        cls=encoder,
        separators=_SEPARATORS)  # pytype: disable=wrong-arg-types
  
    # `text` is an instance of `bytes` if the object to serialize does not contain
    # any unicode characters, otherwise it is `unicode`. See [1] for details.
    #
    # [1]: https://bugs.python.org/issue13769
    if compatibility.PY2 and isinstance(text, bytes):
      text = text.decode("utf-8")  # pytype: disable=attribute-error
  
    return text
docs: Stringifies a Python object into its JSON representation.
  
    Args:
      obj: A Python object to convert to JSON.
      sort_keys: If True, output dictionaries keys in sorted (ascending) order.
      encoder: An (optional) encoder class to use.
  
    Returns:
      A JSON representation of the given object.