[docs]defto_json(data,indent=2,sort_keys=True,ensure_ascii=False):""" Serialize a Python object to a JSON-formatted string with ISO datetime support. This function uses the custom ISODateJSONEncoder to automatically convert datetime.datetime objects to ISO 8601 strings. :param data: The data to serialize (dict, list, etc.). :param indent: Number of spaces to indent in the output JSON. Default is 2. :param sort_keys: Whether to sort the dictionary keys in the output. Default is True. :param ensure_ascii: Whether to escape non-ASCII characters. Default is False. :return: A JSON-formatted string. """returnjson.dumps(data,indent=indent,sort_keys=sort_keys,ensure_ascii=ensure_ascii,cls=ISODateJSONEncoder,)