• Converts a dynamic value to a serializable value. The value must be either an object with a toJSON function, a primitive, or a plain object where all enumerable properties map to values supported by this function. Properties not enumerable will be omitted, properties not serializable will be converted to strings.

    • bigint -> value.toString
    • function -> [function ]
    • symbol -> [symbol ]

    Error instances have a special case where non-serializable errors will still have their name, message, and stack properties serialized.

    Note that this is not intended for use in serializing objects where all values are known; it's intended to cover the case of reporting or logging an unknown object that may or may not be serializable.

    Type Parameters

    • T

    Parameters

    • value: T

    Returns Json<T>