yaml 튜토리얼
yaml 시작하기
수색…
비고
YAML은 " Y AML A in't M arkup L anguage"의 약어입니다. 모든 프로그래밍 언어에 대한 사람이 읽을 수있는 데이터 직렬화 표준입니다.
버전
| 번역 | 출시일 |
|---|---|
| 1.0 | 2004-01-29 |
| 1.1 | 2005-01-18 |
| 1.2 | 2009-10-01 |
기본 Yaml 구문
YAML은 구조화 된 데이터를 계층 구조에 저장할 수있는 텍스트 기반 형식입니다. YAML은 최소한의 오버 헤드로 사람과 기계가 읽을 수 있도록 설계되었습니다. YAML 사양은 yaml.org 에서 찾을 수 있습니다. 참조 카드도 있습니다.
주석은 # 시작하고 개행 할 때까지, 주석은 공백으로 다른 토큰과 분리되어야합니다. 화이트 스페이스는 자유롭지 않습니다. 들여 쓰기는 탭이 아닌 스페이스 여야합니다. YAML은 부모 키보다 더 많은 공백으로 접두어가 붙은 줄이 그 안에 포함되어 있다고 생각할 것입니다. 또한, 모든 행은 동일한 맵에 속하기 위해 동일한 양의 공백으로 접두어를 붙여야합니다.
YAML은 컬렉션 유형으로 시퀀스와 매핑을 가지며, 둘 다 플로우와 블록 스타일로 표현 될 수 있습니다.
YAML의 스칼라 문자열 시퀀스는 다음과 같습니다.
[ one, two, three ] # flow style
# or block style
- one
- two
- three
매핑은 키 / 값 쌍으로 구성됩니다.
index: 4 # block style
name: nali
# or
{ index: 4, name: nali } # flow style
# or nested (equivalent of { level: { one: { two: fun } } }):
level:
one:
two: fun
기본 YAML 유형
integer: 25
string: "25"
float: 25.0
boolean: true
null type: null
YAML 순차적 데이터
같은 목록 수준 :
- Cat
- Dog
- Goldfish
중첩 목록 :
-
- Cat
- Dog
- Goldfish
코멘트
# This comment occupies a whole line
- some item # This comment succeeds content of a line
- http://example.com/#nocomment
- "This # does not introduce a comment."
- |
This is a block scalar.
A # inside it does not introduce a comment.
# unless it is less indented than the first line (this is one)
# 에 주석을 추가하려면 반드시 #
- 선의 시작 부분에서 발생하거나
- 공백이 앞에 와야합니다.
# 항상 공백이 와야합니다. # 인용 된 스칼라 안에는 결코 주석이 시작되지 않습니다. # 는 블록 스칼라 끝에 주석을 삽입 할 수 있지만 블록 스칼라의 기본 들여 쓰기 (일반적으로 첫 번째 비어 있지 않은 행의 들여 쓰기로 결정됨)보다 들여 쓰기가 적어야합니다.
블록 스타일 매핑
암시 적 키 사용 :
key: value
another key:
- some
- more
- values
[1, 2, 3]: last value, which has a flow style key
암시 적 및 명시 적 키 사용 :
? key
: value
another key:
- some
- more
- values
? [1, 2, 3]
: last value, which has a flow style key
key , another key 및 [1, 2, 3] 은 서로 다른 키 스타일을 사용하지만 동일한 매핑의 키입니다.
중첩 된 매핑 :
first level:
second level:
? third level
:
forth level: value of implicit key
? third level, second key
: value of explicit key
?
mapping as: key of
another: mapping
: scalar value of mapping key
first level, second key:
last value
여러 줄로 텍스트 문자열 나누기
- Without quotes:
You can just
split a long piece of text like this.
- With quotes:
"[But be careful:
if you \"need\" punctuation, put double quotes around it. You can ev\
en split without spaces by using backslashes."
- Or single quotes:
'This works
but isn''t as flexible'
- If you want to keep those new line characters: |
Then do
it this way with
a pipe (|) character. (This string has three \n characters)
- Or you can have just the one final new line: >
This string has
just one \n character, at the very end.
- Block indicators:
Look up >-, >+, |- and |+ for fine tuning.
이스케이프 문자
YAML은 이스케이프 표기법의 세 가지 스타일을 지원합니다.
엔티티 이스케이프
에이. space : "& # x20;"
비. 콜론 : "& # 58;"
기음. 앰퍼샌드 : "& amp;"
유니 코드 이스케이프
에이. space : "\ u0020"
비. 작은 따옴표 : "\ u0027"
기음. 큰 따옴표 : "\ u0022"
인용 이스케이프
에이. 작은 따옴표로 큰 따옴표 붙이기 : '나는 항상 진실한 말을하고 있는가?'
비. 중첩 된 큰 따옴표 : "그녀는"나는 그만 뒀다 "고 말했다.
기음. 중첩 된 작은 따옴표 : '그는 말문이났다 :' '