I have created a small Roc library for doing Elm-style JSON decoding. The word "Decoder" was already taken in Roc :) , so you make Recipe
s in this library that describe how you want to try to decode the JSON. Those Recipe
s can then be used to decode bytes, Str
s, or even JSON Value
s (a data type in this library, for valid-but-unknown JSON).
The API is basically Elm's Json.Decode
, with a few helpers from Elm's Json.Decode.Extra
. It also has functions for making JSON Value
s, so it can be used similarly to Elm's Json.Encode
.
This uses lukewilliamboswell/roc-json
under the hood for the actual serialization/deserialization. If you can just use that directly, you should! But if you find yourself needing to decode variably shaped JSON, then I hope this library can be useful to you.
Awesome! I had been thinking recently about how it would be great to have this
Last updated: Jul 06 2025 at 12:14 UTC