waratuman/elm-json-extra/1.0.0

Renamed to waratuman/json-extra. It is published under that name, and new versions come out there.

Versions published as waratuman/elm-json-extra still install under that name. 1 version of 1 come from the new location (see their notes).

Rerouted (renamed, needs approval). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/waratuman/json-extra.

What we checked: The repo moved to github.com/waratuman/json-extra and tag 1.0.0 is there; its commit b36691d8ee47 is from 2019-11-23 04:27 UTC, after the version was published (2019-11-23 04:21 UTC); elm.json differs from package.elm-lang.org's; the exposed modules match docs.json; the zip's SHA-1 is not the published one and nothing else confirms its contents.

We could not verify this copy against what was published, so the Lamdera compiler asks before using it (y/n). Without a terminal, as in CI, it stops with an error unless approved:

  • lamdera make --auto-approve-package-rerouting approves rerouted versions for that run,
  • LAMDERA_AUTO_APPROVE_PACKAGE_REROUTING=1 does the same for every run in that environment,
  • LAMDERA_CACHE=off skips the Lamdera package server altogether: packages come from package.elm-lang.org and GitHub only, as with elm, and a rerouted version then fails to download.

Details · package.elm-lang.org's zip: https://github.com/waratuman/elm-json-extra/zipball/1.0.0/

Json.Encode.Extra

Helper functions for the Json.Decode module of elm/json.

iso8601 : Posix -> Value

Encode a Posix value into a ISO8601 JSON string.

import Json.Encode exposing (..)
import Time


encode 0
    ( object
        [ ( "created_at", iso8601 (Time.millisToPosix 1574447205394 ) ) ]
    )
    --> "{\"created_at\":\"2019-11-22T18:26:45.394Z\"}"
posix : Posix -> Value

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}"
timezone : ( String, Zone ) -> Value

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\"}"
maybe : (a -> Value) -> Maybe a -> Value

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"