Working with JSON
JSON (JavaScript Object Notation) is the last piece of the puzzle we’ll need to solve in order to write our project for this chapter. We need JSON to send the server data to the client in a way that it can understand, and the client has to be able to decode the JSON object into ReasonML data types.
There are two main JSON libraries for ReasonML: bs-json[34] and bs-decode.[35] The main differences are:
-
bs-json can be used in a way that throws exceptions when it finds bad JSON, whereas bs-decode always returns an option or Belt.Result when it encounters errors.
-
bs-json has facilities for parsing and encoding JSON, whereas bs-decode devotes itself purely to decoding, as its name indicates.
In this section, we’ll go with
Get Web Development with ReasonML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.