YAML serialization


The yaml vocabulary implements YAML serialization/deserialization. It uses LibYAML, a YAML parser and emitter written in C (https://pyyaml.org/wiki/LibYAML).

Main conversion words
>yaml ( obj -- str )

>yaml-docs ( seq -- str )

yaml> ( str -- obj )

yaml-docs> ( str -- arr )


Next topics:
Mapping between Factor and YAML types
Special mapping keys
YAML errors
YAML control variables

Examples

Input
USING: prettyprint yaml ; "- true - null - ! 42 - \"42\" - 42 - 0x2A - 0o52 - 42.0 - 4.2e1" yaml> .
{ t f "42" "42" 42 42 42 42.0 42.0 }


Output -- human readable
USING: yaml yaml.config ; t implicit-tags set t implicit-start set t implicit-end set +libyaml-default+ emitter-canonical set +libyaml-default+ emitter-indent set +libyaml-default+ emitter-width set +libyaml-default+ emitter-line-break set t emitter-unicode set { H{ { "name" "Mark McGwire" } { "hr" 65 } { "avg" 0.278 } } H{ { "name" "Sammy Sosa" } { "hr" 63 } { "avg" 0.288 } } } >yaml print
- name: Mark McGwire hr: 65 avg: 0.278 - name: Sammy Sosa hr: 63 avg: 0.288


Output -- verbose
USING: yaml yaml.config ; f implicit-tags set f implicit-start set f implicit-end set +libyaml-default+ emitter-canonical set +libyaml-default+ emitter-indent set +libyaml-default+ emitter-width set +libyaml-default+ emitter-line-break set t emitter-unicode set { t 32 "foobar" { "nested" "list" } H{ { "nested" "assoc" } } } >yaml print
--- !!seq - !!bool true - !!int 32 - !!str foobar - !!seq - !!str nested - !!str list - !!map !!str nested: !!str assoc ...