Scalar Data Types of YAML - YAML Example

YAML supports some basic data types which can be used with programming languages such as −

  • Scalars − strings or numbers or boolean or null.
  • Sequences − arrays or lists.
  • Mappings − hashes or dictionaries.

The following data types are scalar Data Types of YAML:

  • String
  • Boolean value
  • Integer
  • Floating point
  • Null
  • time
  • date

1. SCALAR TYPES:

1.1 Boolean Type:

Boolean_type_1: yesBoolean_type_2: noBoolean_type_3: TrueBoolean_type_4: TRuEBoolean_type_5: falseBoolean_type_6: TRUEBoolean_type_7: nO

1.2 Null Type:

null_type_1: null_type_2: nullnull_type_3: ~

1.3 Integer & Floating point Type

number_type_1: 123number_type_2: 1.23number_type_3: .23number_type_4: 1number_type_5: 1.2e-11number_type_6: 1.2e+11    # Do not use 12e+10 other wise it will be treated                           # as srting(same as "12e+10"), always use .(dot)

1.4 String Type

string_type_1: hellostring_type_2: 'hello'string_type_3: "hello"string_type_4: 1a2string_type_5: 12a   # Note that 12 is number but 12a is stringstring_type_6: "12"  # Note that 12 is number but '12' and "12" are stringstring_type_7: '12'

1.5 Date Type:

date: 2020-02-28	# date typeiso8601: 2001-12-14t21:59:43.10-05:00  #The time is in ISO8601 format.# Enforcing stringsdate_as_string: !str 2020-02-28   # date type