Utilities for taking a JsonValue and generating code for it using
elm-codegen.
A configuration object when generating elm-codegen decoders.
The decoderExpressionType is an optional configuration for customizing how the expression generated by
the decoder function will be annotated. Providing an annotation will overwrite whatever annotation would
normally be generated.
Returns a Json.Decode expression for use in elm-codegen.
For example, running the following code:
toDecoder (StringVal "test")Will result in:
( Gen.Json.Decode.string, Dict.empty )Note: This function may also return a declaration for a custom map function if the passed JsonValue is
a record with more than 8 keys. When returned, this should be added to the generated code!
Takes a JsonToElm.JsonValue and turns it into a Json.Encode expression.
For example, running the following code:
toEncoder (StringVal "test")Will result in:
Gen.Json.Encode.call_.stringReturns a Elm.Expression for use in elm-codegen.
For example, running the following code:
toElmJsonValue (JsonString "test")Will result in:
Elm.string "test"
Returns a
Elm.Type.Annotationfor use in elm-codegen.For example, running the following code:
Will result in: