Jsont_typegistDerive JSON types from OCaml type gists.
The derivation assumes that the JSON type is used to serialize OCaml values to be read back by the derivation itself. Do not use (or perhaps only partially) for devising a nice JSON format or as a proxy for parsing a JSON format into OCaml values.
val to_jsont : versioned:bool -> 'a Typegist.Type.Gist.t -> 'a Jsont.tto_jsont ~versioned g is a JSON type derived fom g. In general the result uses:
Typegist.Type.Gist.name for Jsont.kind.Typegist.Type.Gist.doc for Jsont.doc.If versioned is true the derivation is wrapped in a top-level case object that holds the current version of the derivation. This makes your serializations robust to potential future changes in the derivation. This does not however version your own data, use Typegist.Type.Gist.abstract for that.
Overriding. The JSON type can be selectively overriden on a gist or field with the Jsont_typegist.Jsont and Jsont_typegist.Mem_map metadata keys. This happens before ignoring (see below).
Ignoring Gists or fields whose Typegist.Type.Gist.Meta.Ignore metadata key is true are ignored. However in this case they must define a Typegist.Type.Gist.Meta.Default value otherwise the derivation is undefined. Ignored values or fields are serialized as null and deserialized as null only and replaced by the default value. If you want a gist or field to be ignored only for the purpose of JSON type derivation you can override to_json with Jsont_typegist.Jsont.ignore or Mem_map.ignore.
Warning. Do not assume that the name of an ignored field is secret. While the serializer does not output it by using the enc_omit argument of Jsont.Object.mem, it's presence in JSON will parse (and thus signal its existence) not error. However it will only parse as a null value, no data can be injected.
Undefined. Unless ignored (see above), the function raises Invalid_argument in these cases:
Typegist.Type.Gist.Meta.Ignore is specified on a field but the field has no Typegist.Type.Gist.Meta.Default value.module Mem_map : sig ... endCustom member map field metadata key.