Stream: show and tell

Topic: roc-json-value: Elm-style JSON decoding


view this post on Zulip Ben Thomas (enkidatron) (Jun 09 2025 at 21:00):

I have created a small Roc library for doing Elm-style JSON decoding. The word "Decoder" was already taken in Roc :) , so you make Recipes in this library that describe how you want to try to decode the JSON. Those Recipes can then be used to decode bytes, Strs, or even JSON Values (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 Values, 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.

view this post on Zulip Isaac Van Doren (Jun 09 2025 at 22:27):

Awesome! I had been thinking recently about how it would be great to have this


Last updated: Jul 06 2025 at 12:14 UTC