YAML Process Flow
YAML follows a standard procedure for Process flow.
The Representation Node Graph is the representations of native data structure in YAML as nodes.
The YAML process flow includes mappings, sequences, and scalar quantities that are serialized to create a serialization tree.
With serialization, objects are converted into streams of bytes.
The reverse procedure parses the byte stream into a serialized event tree. Next, the nodes are converted into a graph of nodes. These values are then converted into a native YAML data structure.
![imgs/007_img_yaml_process_flow.jpg](Process Flow of YAML)
The information in YAML is used in two ways: machine processing and human consumption.
The processor in YAML is used as a tool for the procedure of converting information between complementary views in the above diagram.
YAML includes a serialization procedure to represent data objects in serial format. The processing of YAML information includes three stages:
- Presentation and parsing
Let's see each stage in details.
YAML represents the data structure using three kinds of nodes:
You can learn more about datatypes in YAML in the Datatypes Chapter
Scalars represent standard values of strings, integers, dates and atomic data types.
YAML also includes nodes which specify the data type structure.
Sequence refers to the ordered number of entries, which maps the unordered association of key value pair.
- sku : BL123D
quantity : 4
description : Basketball
price : 250.00
- sku : BL3214H
quantity : 1
description : Super Shoes
price : 99.00
Mapping on the other hand represents dictionary data structure or hash table.
keyMapping: <What goes here?>
Serialization process is required in YAML that eases human friendly key order and anchor names.
The result of serialization is a YAML serialization tree.
It can be traversed to produce a series of event calls of YAML data.
An example of serialization is shown below:
filters: ['customer.search', 'customer.order', 'customer.boolean']
The final output of YAML serialization is called presentation.
It represents a character stream in a human friendly manner.
YAML processor includes various presentation details for creating stream, handling indentation and formatting content.
This complete process is guided by the preferences of user.
An example for YAML presentation process is the result of JSON value created:
Parsing is the inverse process of presentation:
- It includes a stream of characters and creates a series of events.
- It discards the details introduced in the presentation process which causes serialization events.
The parsing procedure may fail due to malformed input.
This is basically a procedure to check whether YAML is well-formed or not.
Remember that the three dashes represent the beginning of a document with various attributes defined later.