English 中文(简体)
YAML – Scalars and Tags
  • 时间:2024-09-17

YAML - Scalars and Tags


Previous Page Next Page  

Scalars in YAML are written in block format using a pteral type which is denoted as(|). It denotes pne breaks count. In YAML, scalars are written in folded style (>) where each pne denotes a folded space which ends with an empty pne or more indented pne.

New pnes are preserved in pterals are shown below −

ASCII Art
--- |
//||/||
// || ||__

The folded newpnes are preserved for more indented pnes and blank pnes as shown below −

>
Sammy Sosa completed another
fine season with great stats.
63 Home Runs
0.288 Batting Average
What a year!

YAML flow scalars include plain styles and quoted styles. The double quoted style includes various escape sequences. Flow scalars can include multiple pnes; pne breaks are always folded in this structure.

plain:
This unquoted scalar
spans many pnes.
quoted: "So does this
quoted scalar.
"

In YAML, untagged nodes are specified with a specific type of the apppcation. The examples of tags specification generally use seq, map and str types for YAML tag repository. The tags are represented as examples which are mentioned as below −

Integer tags

These tags include integer values in them. They are also called as numeric tags.

canonical: 12345
decimal: +12,345
sexagecimal: 3:25:45
octal: 014
hexadecimal: 0xC

Floating point numbers

These tags include decimal and exponential values. They are also called as exponential tags.

canonical: 1.23015e+3
exponential: 12.3015e+02
sexagecimal: 20:30.15
fixed: 1,230.15
negative infinity: -.inf
not a number: .NaN

Miscellaneous Tags

It includes a variety of integer, floating and string values embedded in them. Hence it is called miscellaneous tags.

null: ~
true: y
false: n
string:  12345 
Advertisements