61yaml Module
61.1Overview
The yaml
module provides measures to read/write YAML files. You can use this module as a measure to serialize and deserialize objects that consists of list
, dict
and string
instances.
Below is an example to reconstruct values from YAML text:
txt = '''
key1:
- item-A
- item-B
- item-C
key2:
- item-D
- item-E
- item-F
'''
x = yaml.parse(txt)
// x has the following value:
// %{
// 'key1' => ['item-A', 'item-B', 'item-C']
// 'key2' => ['item-D', 'item-E', 'item-F']
// }
61.2Correspondance of Data Object
The below table shows how YAML data types correspond to Gura's value types each other:
YAML Data Type | Gura's Value Type |
---|---|
sequence |
list |
mapping |
dict |
scalar |
string |
61.3Module Function
yaml.compose(obj)
Composes YAML text to represent the content of
obj
that consists of list
, dict
and string
instances.
yaml.parse(str:string)
Parses YAML text in
str
and returns a composition of list
, dict
and string
instances.
yaml.read(stream:stream:r)
Parses YAML text from
stream
and returns a composition of list
, dict
and string
instances.
yaml.write(stream:stream:w, obj):reduce
Composes YAML text to represent the content of
obj
that consists of list
, dict
and string
instances and writes the result to stream
.
61.4Thanks
This module uses yaml library which is distributed in the following site: