
yaml.pl -- Process YAML data
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.
yaml_read(+Input, -DOM) is det- Parse Input to a YAML 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),
nulland the booleanstrueandfalse. Other untagged values are returned as a Prolog string. Tagged values are returned astag(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:!!binaryconverts the Base64 to a string of bytes.!!strexplicitly keeps a string!!nulltranslates "null" tonull!!booltranslates totrueandfalse!!inttranslates to an integer!!floattranslates to a float- Anything else is returned as
tag(Tag, String)
yaml_write(+Out:stream, +DOM) is det
yaml_write(+Out:stream, +DOM, +Options) is det- Emit a YAML DOM object as a serialized YAML document to the stream
Out. Options processed are:
- canonical(+Boolean)
- Use canonical representation. Default is
false. - unicode(+Boolean)
- Use unicode Default is
true. - implicit(+Boolean)
- Use implicit or explicit representation. Currently only
affects the opening and closing the document. Default is
true. Usefalsefor embedded documents. - factorize(+Boolean)
- If
true, minimize the term by factoring out common structures and use&anchorand*anchor. Factorization is always used if DOM is a cyclic term.
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
yaml_write(+Out:stream, +DOM) is det
yaml_write(+Out:stream, +DOM, +Options) is det- Emit a YAML DOM object as a serialized YAML document to the stream
Out. Options processed are:
- canonical(+Boolean)
- Use canonical representation. Default is
false. - unicode(+Boolean)
- Use unicode Default is
true. - implicit(+Boolean)
- Use implicit or explicit representation. Currently only
affects the opening and closing the document. Default is
true. Usefalsefor embedded documents. - factorize(+Boolean)
- If
true, minimize the term by factoring out common structures and use&anchorand*anchor. Factorization is always used if DOM is a cyclic term.