Yaml encoder/decoder for OCaml jsont codecs

Compare changes

Choose any two refs to compare.

Changed files
+9 -1
.tangled
workflows
lib
+1
.tangled/workflows/build.yml
···
- bzip2
- gcc
- ocaml
steps:
- name: opam
···
- bzip2
- gcc
- ocaml
+
- pkg-config
steps:
- name: opam
+8 -1
lib/yamlt.mli
···
let from_yaml = Yamlt.decode_string Config.jsont yaml_str
]}
See notes about {{!yaml_mapping}YAML to JSON mapping},
{{!yaml_scalars}YAML scalar resolution}, and
{{!null_handling}null value handling}. *)
···
setting of the default value (e.g. 0 and [null] for an integer would be
indistinguishable).
-
To accept null for primitive fields, explicitly use {!Jsont.option}:
{[
(* Accepts null, decodes as None *)
Jsont.Object.mem "count" (Jsont.option Jsont.int) ~dec_absent:None
···
let from_yaml = Yamlt.decode_string Config.jsont yaml_str
]}
+
{2 Related Libraries}
+
+
{ul
+
{- [Jsont] - JSON codec library whose type descriptions this library interprets}
+
{- [Yamlrw] - Pure OCaml YAML parser/emitter used for low-level YAML processing}
+
{- [Bytesrw] - Byte-level I/O abstraction for streaming encode/decode}}
+
See notes about {{!yaml_mapping}YAML to JSON mapping},
{{!yaml_scalars}YAML scalar resolution}, and
{{!null_handling}null value handling}. *)
···
setting of the default value (e.g. 0 and [null] for an integer would be
indistinguishable).
+
To accept null for primitive fields, explicitly use {!val:Jsont.option}:
{[
(* Accepts null, decodes as None *)
Jsont.Object.mem "count" (Jsont.option Jsont.int) ~dec_absent:None