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: |
   Line1
   line2
   "line3"   
  line4

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

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

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