This is an OCaml library to parse and generate the YAML file format. It is intended to interoperable with the Ezjsonm JSON handling library, if the simple common subset of Yaml is used. Anchors and other advanced Yaml features are not implemented in the JSON compatibility layer.
The Yaml module docs are browseable online.
Example of use
Install the library via
opam install yaml, and then execute a toplevel via
utop. You can also build and execute the toplevel locally:
$ opam install yaml $ utop # #require "yaml";; # Yaml.of_string "foo";; - : Yaml.value Yaml.res = Result.Ok (`String "foo") # Yaml.of_string "- foo";; - : Yaml.value Yaml.res = Result.Ok (`A [`String "foo"]) # Yaml.to_string (`O ["foo1", `String "bar1"; "foo2", `Float 1.0]);; - : string Yaml.res = Result.Ok "foo1: bar1\nfoo2: 1.\n"
The README contains more information about how the library is structured. This repository is a reasonable example of how to use ocaml-ctypes and stub generation to bind to a C library without writing any actual C code for the bindings.