Variable asObjectConst

asObject: ObjectDecoder<{}> = ...

A decoder for objects, with additional methods that are used to specify decoders for fields.

An object decoder will and can decode from any object that is a superset of this object without failure. This means that using a decoder that decodes two string fields on an object with 10 string fields will succeed provided that the two fields it expects are among those 10 fields.

The decoded value will always be exactly what was specified. No more, no less.

example:

asObject
.withField("field1", asString) // decoder for { field1: string }
.withField("field2", asBoolean) // decoder for { field1: string, field2: boolean }
.withField("field3", asObject.withField("innerField", asArray(asNumber)))

the above produces a decoder for

  {
field1: string,
field2: boolean,
field3: {
innerField: number[]
}
}

Type declaration

    Generated using TypeDoc