def METHOD_NAME(self, pretty: bool = False) -> str:
    """
    to_json serialises type to JSON.
    :return: valid JSON unicode string.
    :rtype: str
    """
    if pretty:
        out = json.dumps(self.to_obj(), indent=2, sort_keys=True)
    else:
        out = json.dumps(self.to_obj())
    return out