YAML - Sample Example

This tutorial covers YAML tutorials,Multiline Strings with literal block and folded styles with indentation examples.

yaml example file strings

YAML file example is documented with all the basic components of yaml file.

Official standard of file extension is .yaml

Let’s see an sample yaml document with basic components syntax

---  # yaml document begining
# comment syntax

# basic syntax - key and value separated by colon and space before value
key: value

# Scalar data types
integerValue: 1                     # integer value
floatingValue: 1                     # floating vale

stringValue: "456"                   # string with double quotes
stringValue: 'abc'                  # string with single quotes
stringValue: wer                   # string without quotes

booleanValue:true                   # boolean values - true or false

# Multiline strinsg with literal block syntax -preserved new lines
string1: |

# Multiline strings with folded block syntax - new lines are not preserved, leading and trailing spaces are ignore
  string1: >
# Collection sequence data types
 # sequence arraylist example
 - One
 - two
 - Three

  # other way of sequence  syntax example
  [one, two ,three]

### dictionary
    hostname: localhost
    port: 3012
    username: root
    password: root