Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Yaml
A library for parsing and emitting YAML.
It is based on a binding to libyaml which covers the generation and parsing processes.
Most simple use cases can simply use the of_string and to_string functions, which are compatible with the Ezjsonm types. This means that you can convert between JSON and Yaml format easily.
If you use more advanced Yaml features such as aliases or anchors, then the yaml type and yaml_of_string and yaml_to_string functions will be more useful. The library does not yet support expanding aliases into the JSON format from YAML, so that will currently result in an error.
value is the subset of a Yaml document that is compatible with JSON. This type is the same as Ezjsonm.value, and so most simple uses of Yaml can be interchanged with JSON.
val sexp_of_value : value->Ppx_sexp_conv_lib.Sexp.t
val value_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->value
val __value_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->value
yaml is the representation of a Yaml document that preserves alias information and other Yaml-specific metadata that cannot be represented in JSON. It is not recommended to convert untrusted Yaml with aliases into JSON due to the risk of denial-of-service via a Billion Laughs attack.
and anchor_string = {
anchor : string option;
value : string;
}
yaml is the representation of a Yaml document that preserves alias information and other Yaml-specific metadata that cannot be represented in JSON. It is not recommended to convert untrusted Yaml with aliases into JSON due to the risk of denial-of-service via a Billion Laughs attack.
anchor_string holds a possible Yaml anchor, and the string value
val sexp_of_anchor_string : anchor_string->Ppx_sexp_conv_lib.Sexp.t
val yaml_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->yaml
val __yaml_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->yaml
val anchor_string_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->anchor_string
type version = [
| `V1_0
| `V1_1
]
Version of the YAML spec of a document. Refer to the Yaml specification for details of the differences between versions.
val sexp_of_version : version->Ppx_sexp_conv_lib.Sexp.t
val version_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->version
val __version_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->version
type encoding = [
| `Any
| `Utf16be
| `Utf16le
| `Utf8
]
Document encoding. The recommended format is Utf8.
val sexp_of_encoding : encoding->Ppx_sexp_conv_lib.Sexp.t
val encoding_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->encoding
val __encoding_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->encoding
type scalar_style = [
| `Any
| `Plain
| `Single_quoted
| `Double_quoted
| `Literal
| `Folded
]
YAML provides three flow scalar styles: double-quoted, single-quoted and plain (unquoted). Each provides a different trade-off between readability and expressive power. The Yaml spec section 7.3 has more details.
val sexp_of_scalar_style : scalar_style->Ppx_sexp_conv_lib.Sexp.t
val scalar_style_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->scalar_style
val __scalar_style_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->scalar_style
type layout_style = [
| `Any
| `Block
| `Flow
]
Mappings and sequences can be rendered in two different ways:
Flow styles can be thought of as the natural extension of JSON to cover folding long content lines for readability, tagging nodes to control construction of native data structures, and using anchors and aliases to reuse constructed object instances.
Block styles employ indentation rather than indicators to denote structure. This results in a more human readable (though less compact) notation.
val sexp_of_layout_style : layout_style->Ppx_sexp_conv_lib.Sexp.t
val layout_style_of_sexp : Ppx_sexp_conv_lib.Sexp.t ->layout_style
val __layout_style_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t ->layout_style
to_string v converts the JSON value to a Yaml string representation. The encoding, scalar_style and layout_style control the various output parameters. The current implementation uses a non-resizable internal string buffer of 16KB, which can be increased via len.
yaml_to_string v converts the Yaml value to a string representation. The encoding, scalar_style and layout_style control the various output parameters. The current implementation uses a non-resizable internal string buffer of 16KB, which can be increased via len.
to_json yaml will convert the Yaml document into a simpler JSON representation, discarding any anchors or tags from the original. Returns an error if any aliases are used within the body of the Yaml input.