Function serialize

  • Serialize given data structure to JSON data objects (not a JSON string).

    The resulting JSON object can be stringified using JSON.stringify().

    interface Data {
    created: Date;
    }

    const json = serialize<Data>({created: new Date(1234567890123)});
    //json is {created: '2009-02-13T23:31:30.123Z'}

    const jsonString = JSON.stringify(json);
    //jsonString is '{"created":"2009-02-13T23:31:30.123Z"}'

    Throws

    ValidationError when serialization or validation fails.

    Type Parameters

    • T

    Parameters

    Returns JSONSingle<T>

Generated using TypeDoc