ts.data.json - v4.1.0
    Preparing search index...

    Type Alias DecoderObject<T>

    DecoderObject: {
        [P in keyof Required<T>]:
            | Decoder<T[P]>
            | { decoder: Decoder<T[P]>; fromKey: string }
    }

    Represents an object that maps properties of a TypeScript type T to decoders used to validate raw JSON values. Each property may either be a Decoder<T[P]> (decoding a field from the same key in the input JSON) or an object with fromKey and decoder to decode from a different input key.

    The fromKey option is useful when your TypeScript property name differs from the incoming JSON key (for example, snake_case JSON keys mapped to camelCase TypeScript properties). Errors reported still reference the TypeScript property name (the key of DecoderObject).

    Type Parameters

    • T
    // Example where the JSON has `first_name`, but our TypeScript property is `firstName`
    interface User { firstName: string; lastName: string; age: number }

    const decoders: DecoderObject<User> = {
    firstName: { fromKey: 'first_name', decoder: JsonDecoder.string() },
    lastName: { fromKey: 'last_name', decoder: JsonDecoder.string() },
    age: JsonDecoder.number()
    };