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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access