YAML Character streams - YAML

What are YAML Character streams?

In YAML, you come across various character streams as follows −

  • Directives
  • Document Boundary Markers
  • Documents
  • Complete Stream

In this chapter, we will discuss them in detail.


Directives are essential example lines utilized in YAML processor. Directives are the presentation subtleties like comments which are not reflected in serialization tree. In YAML, there is no real way to characterize private directives. This segment talks about different types of directives with pertinent examples −

Reserved Directives

Reserved directives are instated with three hyphen characters (- - ) as appeared in the model below. The reserved directives are changed over into explicit estimation of JSON.

YAML Directive

YAML Directives are default directives. Whenever changed over in JSON, the values brought incorporates forward slice character in going before and ending characters.

Document Boundary Markers

YAML utilizes these markers to enable more than one Document to be contained in one stream. These markers are uniquely used to pass on the structure of YAML report. Note that a line starting with "- - "is utilized to begin another Document.

The accompanying code clarifies about this with examples –


YAML Document is considered as a solitary local data structure introduced as a solitary root node. The presentation subtleties in YAML report, for example, directives, comments, Indentation and styles are not considered as content incorporated into them.

There are two Types of Documents utilized in YAML. They are clarified in this segment −

Explicit Documents

It starts with the report begin marker pursued by the presentation of the root node. The example of YAML express statement is given below −

It incorporates an unequivocal begin and end markers which is "- - "and "… " in given example. On changing over the predefined YAML in JSON format, we get the output as appeared below –

Implicit Documents

These reports don't start with a Document begin marker. Watch the code given below –

Changing over these qualities in JSON format we get the output as a straightforward JSON object as given below –

Complete Stream

YAML incorporates a sequence of bytes called as character stream. The stream starts with a prefix containing a byte arrange indicating a character encoding. The entire stream starts with a prefix containing a character encoding, trailed by comments.

A example of finish stream (character stream) is appeared below –

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

YAML Topics