Json encode/decode in Js_of_ocaml

You can use what @zbaylin mentions but note that this API will simply return/take for now a JavaScript object, it uses your browser’s JSON.{parse,stringify} functions.

So if you are looking to codec OCaml values you will have to further query the object with the Jv module which is quite low level (e.g. see the to,of_json functions in the model of the todomvc example, note that the functions there do not handle errors).

In the future I’d like to provide a few combinators to easily interoperate with OCaml values, that’s the reason for the warning about the fact that this interface will likely change in the future.

2 Likes