Decoder that accepts null values.
The decoder for the non-null value
A decoder that accepts either the decoded value or null
interface User { name: string; age: number | null;}const userDecoder = JsonDecoder.object<User>({ name: JsonDecoder.string(), age: JsonDecoder.nullable(JsonDecoder.number())});userDecoder.decode({name: 'John', age: null}); // Ok<User>userDecoder.decode({name: 'John', age: 30}); // Ok<User> Copy
interface User { name: string; age: number | null;}const userDecoder = JsonDecoder.object<User>({ name: JsonDecoder.string(), age: JsonDecoder.nullable(JsonDecoder.number())});userDecoder.decode({name: 'John', age: null}); // Ok<User>userDecoder.decode({name: 'John', age: 30}); // Ok<User>
Decoder that accepts null values.