Try Install Learn Blog API Packages GitHub
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"])
boolean
(
input
:
Object
)
:
Result(Object.Error, Bool)

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)
number
(
input
:
Object
)
:
Result(Object.Error, Number)

Decodes the object as a Number

Object.Decode.boolean(`0`) == Result::Ok(0)
string
(
input
:
Object
)
:
Result(Object.Error, String)

Decodes the object as a String

Object.Decode.boolean(`"A"`) == Result::Ok("A")
time
(
input
:
Object
)
:
Result(Object.Error, Time)

Decodes the object as a Time

Object.Decode.boolean(`"new Date()"`)