billstclair/elm-versioned-json/1.0.3

VersionedJson

A couple of functions to ease versioning of your JSON representations.

See the README for the examples directory for details.

Classes

type alias ConverterDict x =
Dict Int (String -> Result String x)

An Elm Dict mapping version numbers to decoder functions

Functions

encodeVersionedJson : Int -> x -> (x -> String) -> String

Convert a value to a versioned Json string

decodeVersionedJson : String -> ConverterDict x -> Result String x

Decode a string saved by encodeVersionedJson with the relavant converter function from a dictionary you provide.

If the string is not as encoded by encodeVersionedJson, use the converter function for version 0.