Guess what?! Version 0.3 of data-encoding is now available!
Data-encoding is a library for defining encodings, which can then be used to
serialise and deserialise values to-and-from a binary or JSON representation.
let e : (string * int list) t = obj2 (req "name" string) (list uint8) let v : (string * int list) = ("low", [0;1;2;3;4]) let s : string = Binary.to_string_exn e v let j : Ezjson.t = Json.construct e v
Version 0.3 of the library is now available on opam.
The code is distributed under MIT license and hosted on Gitlab: Nomadic Labs / data-encoding · GitLab.
The documentation is available online: Data_encoding (data-encoding.Data_encoding)
In addition to numerous miscellaneous improvements, this version brings two
Support for streamed JSON serialisation.
JSON serialisation for large values can be expensive. And in some context,
prohibitively so. One such context is cooperative concurrency where
serialising very large JSON values can block other on-going tasks.
Data-encoding provides the necessary functions to serialise values as
sequences of strings which can be consumed with appropriate yielding.
let rec write seq = match seq () with | Seq.Nil -> Lwt.return_unit | Seq.Cons (chunk, seq) -> Lwt_io.write oc chunk >>= fun () -> Lwt.pause () >>= fun () -> write seq in let j = Json.construct_seq e v in let s = Json.string_seq_of_jsonm_lexeme_seq ~chunk_size_hint:512 j in write s
The serialisation and deserialisation of some encodings has been optimised a
lot. On some encodings the performances have gotten competitive with Marshal.
More details below.