Pages
core
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: "Value"}`, "field", Object.Decode.string) == 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(`"A"`, Object.Decode.String) == Result::Ok(Maybe::Just("A"))
Object.Decode.maybe(`null`, Object.Decode.String) == Result::Ok(Maybe::Nothing)
Decodes the object as a Number
Object.Decode.number(`0`) == Result::Ok(0)
Decodes the object as a String
Object.Decode.string(`"A"`) == Result::Ok("A")
Decodes the object as a Time
Object.Decode.time(`"new Date()"`)