• Returns a converter for JSON-compatible objects or values.

    encode first serializes the object or value to JSON and then converts the resulting string to an ArrayBuffer. JSON serialization uses JSON.stringify() without replacer or space parameters.

    decode converts the ArrayBuffer to a string and parses it using JSON.parse() without reviver parameter.

    Example:

    interface Person {
    name: string
    age: number
    }
    const person: Person = { name: "John", age: 42 };
    const conv = ccfapp.json<Person>();
    const buffer = conv.encode(person); // ArrayBuffer
    const person2 = conv.decode(buffer); // Person

    Type Parameters

    • T extends unknown

    Returns DataConverter<T>