Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
Last active April 24, 2022 18:24
Show Gist options
  • Save ibrezm1/e57b17f2eacb3ba582abfc9282c2b113 to your computer and use it in GitHub Desktop.
Save ibrezm1/e57b17f2eacb3ba582abfc9282c2b113 to your computer and use it in GitHub Desktop.
All types of YAML instances
--- # Start of yaml with ---
# https://yaml-online-parser.appspot.com/
# https://www.json2yaml.com/
# https://github.com/josephmachado/beginner_de_project/blob/master/docker-compose.yaml ( Sample usage of anchors )
# Sample YAml
- name: Test
str1: 'HEllo'
str2: 'HEllo2'
- numbers:
num: 1 # Dec
num4: 1.5 # float
num2: 0212 # Octal
num3: 0x122 # Hex
- Special:
Spec1: Yes
Sepc2: True
Sepc3: No
#Spec4: .inf # Infinity not allowed in Json
#Spec5: -.inf
Spec6: ~
Spec7: null
- Strings:
test1: "test String"
test2: |
test String
Has multiple lines
and it is conserved
test3: >
test String
Has multiple lines
and it is NOT conserved
test5: "Special#@!<> Charaters need doubel quotes"
test6: |+
Retain trailing
Newline
- StringsExplicit: # Forced types else validation failes
test1: !!bool True
test2: !!int 3
test3: !!float 3.2
test4: !!str Hello
test5withspace: !!timestamp 2022-12-12 12:12:12.12 -5
test6-iso: !!timestamp 2022-12-12t12:12:12.12-05:00
- Listscreated:
- item1
- item2
- item3
- Listscreatedoflists:
- item1:
- item11
- item2:
- item21
- item3:
- item311
- item322
- DictinoryCreated:
- test:
name: Class
date: Somedate
test: best
- test2:
name: Class
date: Somedate
test: best
- Complexkeys:
- ? This key is
complex multiline
: Test
- Anchors:
- weekday: &working
wakeup: 8am
activities:
- jogging
- testing
- fighting
sleeptime: 10:00 pm
- ApplyAncohrs:
- Monday: *working
- Thursday: *working
- Friday:
<<: *working
sleeptime: 12:00 AM
... # End of yaml with three dots
--- # Multi Document yaml no extra newlines ater end of ...
#Json does not support multi doucment
name: NewYaml
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment