Formerly waratuman/elm-json-extra. Search finds this package by either name.
Helper functions for the Json.Decode module of elm/json.
Decode an ISO8601 JSON string into a Posix.
import Json.Decode exposing (..)
import Time
decodeString (field "created_at" date) "{ \"created_at\": \"2019-11-22\"}"
--> Ok (2019, Time.Nov, 22)Decode an ISO8601 JSON string into a Posix.
import Json.Decode exposing (..)
import Time
decodeString (field "created_at" iso8601)
"{ \"created_at\": \"2019-11-22T18:26:45Z\"}"
--> Ok (Time.millisToPosix 1574447205000)Decode a JSON float value representing the number of seconds since epoch
into a Posix.
import Json.Decode exposing (..)
import Time
decodeString (field "created_at" posix)
"{ \"created_at\": 1574447205.394}"
--> Ok (Time.millisToPosix 1574447205000)Decode a timezone JSON string value into a Zone.
import Json.Decode exposing (..)
import TimeZone
decodeString (field "timezone" timezone)
"{ \"timezone\": \"America/Los_Angeles\"}"
--> Ok ("America/Los_Angeles", TimeZone.america__los_angeles ())
Decode a JSON value and do nothing with it.