Stream: show and tell

Topic: Json String Decoding


view this post on Zulip Luke Boswell (Mar 25 2023 at 08:19):

On a run with Json; so thought I might share my string decoder which complies with IETF RFC 8259 and handles utf8 encoded json. You can see the implementation here in this gist.

Found a few more bugs (5191, 5192, 5193) which made this a bit of a challenge. But again, having lots of unit tests and just slowly composing things together was pretty reliable.

If you are interested in trying it out, you can copy and paste into a random file and roc run to see it in action, please let me know if you find any json compliant strings that break it.

% roc test JsonStr.roc

0 failed and 17 passed in 527 ms.

% roc run JsonStr.roc
The secret json encoded string is
"""
h   ello

"""

Last updated: Jul 05 2025 at 12:14 UTC