On behalf of Nomadic Labs, I’m happy to announce the release of json-data-encoding version 0.9.
The code is hosted on Gitlab: Nomadic Labs / json-data-encoding · GitLab
It is distributed under GNU LGPL with linking exception.
The documentation is available online: index
The package is available under opam:
opam install json-data-encoding
json-data-encoding is a library to define encoder/decoder values to translate OCaml values to JSON and back. It also generates JSON schemas so you can document the value representation. It can use either Ezjsonm or Yojson as backends.
The version 0.9 has the following new features:
- more tests
- memoisation of fixpoint encoding to avoid repeated computations
- support for
formatfield for string schemas (see string — Understanding JSON Schema 7.0 documentation) (contributed by @levillain.maxime)
- fixed integer bound printing in schemas (bug report by @pw374)
- support for json-lexeme streaming (see details below)
- support for inclusion/exclusion of default-value fields during serialisation (contributed by @levillain.maxime)
- improved union-of-object schemas (contributed by @levillain.maxime)
One major difference with the previous release is the inclusion of a lexeme-streaming JSON constructor. Specifically, the function
val construct_seq : 't encoding -> 't -> jsonm_lexeme Stdlib.Seq.t
generates a sequence of
Jsonm.lexeme (the . This sequence is lazy (in the sense of
Stdlib.Seq not of
Stdlib.Lazy) and it paves the way to a similar feature in
data-encoding. An interesting feature of sequences is that they can be used in Vanilla OCaml settings as well as Lwt/Async settings where they allow user-driven yielding in between elements.