YAML (데이터 직렬화)
XML, JSON 과 같은 데이터 직렬화 방식
최대한 간결하게 파이프라인을 구성하도록 되어있음
Tag
tag를 통해 데이터 구조를 명확히 지칭
일부 seq, map, object map, set 은 암시적인 tag로 적용됨
map:
Block style: !!map
Clark : Evans
Oren : Ben-Kiki
데이터 구조 (Collection Types)
seq, array (!!seq)
Block style:
- one
- two
- three
Flow style: [one, two, three]
map (!!map)
map:
# Unordered set of key: value pairs.
Block style:
Clark : Evans
Ingy : döt Net
Oren : Ben-Kiki
Flow style: { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }
object map (!!omap)
objectMap:
Block style:
- one: 1
- two: 2
- three : 3
Flow style: [ one: 1, two: 2, three : 3 ]
set (!!set)
set:
Block tasks:
? Mark McGwire
? Sammy Sosa
? Ken Griffey
# Flow style
Flow style: { Boston Red Sox, Detroit Tigers, New York Yankees }
pair (tag need / !!pairs)
pairs:
Block tasks: !!pairs
- meeting: with team.
- meeting: with boss.
- break: lunch.
- meeting: with client.
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
데이터 타입 (Scalar Types)
#========================================== string
string: abcd
swap string every line: |
a
long
string
swap string last line: >
a
long
string
#========================================== bool
bool:
- true
- True
- TRUE
- false
- False
- FALSE
#========================================== float
float:
canonical: 6.8523015e+5
exponentioal: 685.230_15e+03
fixed: 685_230.15
negative infinity: -.inf
not a number: .NaN
#========================================== int
int:
canonical: 685230
decimal: +685_230
octal: 0o2472256
hexadecimal: 0x_0A_74_AE
binary: 0b1010_0111_0100_1010_1110
#========================================== null
null:
# This mapping has four keys,
# one has a value.
empty:
canonical: ~
english: null
~: null key
# This sequence has five
# entries, two have values.
sparse:
- ~
- 2nd entry
-
- 4th entry
- Null
#========================================== timestamp
timestamp:
canonical: 2001-12-15T02:59:43.1Z
valid iso8601: 2001-12-14t21:59:43.10-05:00
space separated: 2001-12-14 21:59:43.10 -5
no time zone (Z): 2001-12-15 2:59:43.10
date (00:00:00Z): 2002-12-14
데이터 구조 병합 (Merge)
override 시, 먼저 참조한 데이터의 값을 먼저 사용
#============================================== object
object:
foo: &foo
a: 1
b: 2
bar:
<<: *foo
c: 3
marge object a: &moa
a: 1
b: 2
marge object b: &mob
a: 3
c: 4
marge all:
<<: [*moa, *mob]
marge all with data:
<<: [*moa, *mob]
new data: new
#============================================== list
list:
- &CENTER { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }
- # Explicit keys
x: 1
y: 2
r: 10
label: nothing
- << : *CENTER
r: 10
label: center
- << : [ *CENTER, *BIG ]
label: center/big
- # Override
<< : [ *BIG, *LEFT, *SMALL ]
x: 1
label: big/left/small