Pages
Standard Library
Search
Entities
Object.Decode
Functions
array
(
input
:
Object
decoder
:
Function(Object, Result(Object.Error, a))
)
:
Result(Object.Error, Array(a))
Decodes the object as an Array
using the given decoder.
Object.Decode.array(`["A", "B"]`, Object.Decode.string, ) == Result::Ok(["a", "b"])
Decodes the object as a Bool
Object.Decode.boolean(`true`) == Result::Ok(true)
field
(
input
:
Object
key
:
String
decoder
:
Function(Object, Result(Object.Error, a))
)
:
Result(Object.Error, a)
Decodes a field from an object using the given decoder.
Object.Decode.field(
"field", Object.Decode.string, `{field: "Value"}`) == Result::Ok("Value")
maybe
(
input
:
Object
decoder
:
Function(Object, Result(Object.Error, a))
)
:
Result(Object.Error, Maybe(a))
Decodes the object as a Maybe(a)
using the given decoder.
Object.Decode.maybe(Object.Decode.String, `"A"`) == Result::Ok(Maybe::Just("A"))
Object.Decode.maybe(Object.Decode.String, `null`) == Result::Ok(Maybe::Nothing)
Decodes the object as a Number
Object.Decode.boolean(`0`) == Result::Ok(0)
Decodes the object as a String
Object.Decode.boolean(`"A"`) == Result::Ok("A")
Decodes the object as a Time
Object.Decode.boolean(`"new Date()"`)