JsonCodec 2.0.1

As I mentioned here in a previous post, JsonCodec now makes building codecs for larger records a bit easier.

-- Codec built in application style
type alias Test = { i : Int, b : Bool, f : Float, s : String }

codec =
Test
|> JC.first "i" JC.int .i
|> JC.next "b" JC.bool .b
|> JC.next "f" JC.float .f
|> JC.next "s" JC.string .s
|> JC.end

x = JD.decodeString (JC.decoder codec) "{\"i\":3,\"b\":false,\"f\":3.14,\"s\":\"hi there\"}"
-- Ok { i = 3, b = False, f = 3.14, s = "hi there" }

Happy elm-lang-ing!

Like what you read? Give art yerkes a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.