Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Decoder<T>

A Decoder represents a way to decode JSON into type T. Provided in this module are Decoders for primitive JSON types, as well as a set of higher-order Decoders that can be composed together to decode complex nested objects.

Type parameters

  • T

Hierarchy

  • Decoder

Index

Methods

decodeAny

  • decodeAny(object: any): T
  • Attempt to decode a plain object into a value of type T. Throws a descriptive error if the object does not match the structure described by the decoder.

    Parameters

    • object: any

      Any object.

    Returns T

    A value of the type described by the Decoder.

decodeJSON

  • decodeJSON(json: string): T
  • Attempt to decode some JSON input into a value of type T. Throws a descriptive error if the JSON input does not match the structure described by the Decoder.

    Parameters

    • json: string

      A JSON encoded string.

    Returns T

    A value of the type described by the Decoder.

Generated using TypeDoc