Formerly waratuman/elm-json-extra. Search finds this package by either name.
Helper functions for the Json.Decode module of elm/json.
Encode a Posix value into a JSON float representing the number of seconds
since epoch.
import Json.Encode exposing (..)
import Time
encode 0
( object
[ ( "created_at", posix (Time.millisToPosix 1574447205 ) ) ]
)
--> "{\"created_at\":1574447.205}"Encode a ( String, Zone ) value into a JSON string with the
value being the name of the timezone.
import Json.Encode exposing (..)
import TimeZone
let
losAngeles =
("America/Los_Angeles", TimeZone.america__los_angeles ())
in
encode 0
( object
[ ( "timezone", timezone losAngeles ) ]
)
--> "{\"timezone\":\"America/Los_Angeles\"}"Encode a Maybe value with the given encoder.
import Json.Encode exposing (..)
encode 0 (maybe int Nothing)
--> "null"
encode 0 (maybe int (Just 1))
--> "1"
Encode a
Posixvalue into a ISO8601 JSON string.