SWI-Prolog YAML library
VU University Amsterdam
This package reads and writes
YAML documents from and to SWI-Prolog streams, files and strings. It is
C library is being used by several languages. Using this C library
provides good performance, and interoperability with YALM infrastructure
used by other systems.
This module parses YAML serialized data into a Prolog term with
structure that is compatible with the JSON library. This library is a
wrapper around the C library
libyaml. This library forms
the basis of the YAML support in several languages and thus guarantees
compatibility of our YAML support with other languages.
- Parse Input to a YALM DOM. The DOM
representation uses the following mapping:
- A YAML sequence is mapped to a Prolog List.
- A YAML mapping is mapped to a Prolog dict.
- Untagged scalars follow the implicit tag rules defined by
YAML, providing numbers (int, float and special floats),
null and the booleans
Other untagged values are returned as a Prolog string. Tagged values are
tag(Tag, String) which is processed by
yalm_tagged/3. This internal predicate
calls the user hook
yaml:tagged/3 with the same arguments and,
if the hook fails, provides the following defaults:
!!binary converts the Base64 to a string of bytes.
!!str explicitly keeps a string
!!null translates "null" to
!!bool translates to
!!int translates to an integer
!!float translates to a float
- Anything else is returned as
|Input ||is one of (1) a stream, (2) a term |
or (3) a file name.
- Emit a YAML DOM object as a serialized YAML document to the
Out. Options processed are:
- Use canonical representation. Default is
- Use unicode Default is
- Use implicit or explicit representation. Currently only affects the
opening and closing the document. Default is
false for embedded documents.
true, minimize the term by factoring out common
structures and use
Factorization is always used if DOM is a cyclic term.
- Hook that allows convering
!!tag values to be decoded or