import json
import time


def serialize_spool_file_contents(reason, expiration=None, creation=None):
    """Serialize the contents of the spool file (as JSON).

    :param reason: a string representing the reason why the downtime exists.
    :param expiration: The unix time when this downtime should be considered valid until, or None for no expiry.
    :param creation: The unix time when this downtime was created, or None if unknown.
    :returns: A JSON-formatted dictionary with keys reason, expiration, and creation, corresponding to the parameters.
    """
    return json.dumps({
        "reason": reason,
        "expiration": expiration,
        "creation": (time.time() if creation is None else creation),
    })