the-sett/decode-generic - version: 1.0.0

for more information visit the package's GitHub page

Package contains the following modules:

Decode Generic

Decodes any Json onto a generic model:

type Json
    = JString String
    | JBool Bool
    | JInt Int
    | JFloat Float
    | JNull
    | JObj (Dict String Json)
    | JArr (List Json)

The usual approach in Elm is to write Json.Decode logic that decodes onto a specific user defined type (or type alias). This is a stronger approach and leads to nicely typed data models and better programs, and this approach should not generally be abandoned in favor of using this generic decoder.

There are a couple of situations where a generic decoder can be useful: