본문 바로가기
카테고리 없음

[CE] Syntax of YAML [Simple Version]

by ds31x 2024. 1. 7.

기본적으로 indentation 으로 구조화를 시킴.

indent 는 space 2칸 또는 4칸이 권장됨.

2024.01.07 - [분류 전체보기] - [Term] YAML (Yet Another Markup Language)

 

[Term] YAML (Yet Another Markup Language)

Human-friendly Unicode based Data Serialization Language 인간친화적인 유니코드 기반의 데이터 직렬화 언어 https://yaml.org/spec/1.1/#id857168 YAML Ain’t Markup Language (YAML™) Version 1.1 YAML Ain’t Markup Language (YAML™) Vers

ds31x.tistory.com


1. Key-value Pairs

key: value
  • key 와 value 사이에는 반드시 빈칸이 있어야 함.
  • colon : 뒤에 space 가 필요함.
  • value 가 _colon 을 포함하는 string(문자열)_인 경우엔 반드시 quote 로 시작하고 끝나야 함.

2. Lists

- item0
- item1
- item2

3. Nesting (중첩)

key0:
    key1: value1
    key2: value2
  • indentation (들여쓰기)를 사용하여 구조화를 시킴.

4. Comments (주석)

# This is a comment!

5. Strings

name: "Hang-Kuen"
  • double quote를 빼도 된다.
  • 단, colon 이 문자열에 있는 경우엔 반드시 해당 문자열은 double quote 로 둘러싸져야 함.
  • flow scalar라고도 불림.
  • 아래의 10. Block Scalar (여러줄 문자열) 를 참고할 것.

6. Numbers

age: 43
  • integer 나 real number 를 quote 없이 사용할 경우 숫자로 인식함.

7. Boolean

is_active: true
  • 기본은 true 또는 false 를 사용.
  • yes or no 를 사용하기도 한다.

8. Sequence

- [8, 'Korea']

9. null

key: null

10. Block Scalar (여러줄 문자열)

description: |
    This is a multi-line
    string in YAML
  • | : 마지막 new line이 추가됨.
  • |- : 마지막 new line이 제외됨.
  • > : 중간에 들어간 empty line이 제외됨.

multi-line string에 대한 yaml에서 지원하는 type은 block scalar 또는 flow scalar 임.

flow scalar는 single quoted 또는 double quoted, plain으로 나누어짐. 주의할 것은 plain의 경우 colon 또는 sharp 등이 문자열에 있는 경우 문제가 됨.

YAML에서는 scalar 라는 용어를
array나 list 같은 형태의 데이터 외의
숫자나 문자열과 같이 단순한 형태의 데이터를 가르키는데 사용함.

YAML Multiline Strings

 

YAML Multiline Strings

There are two types of formats that YAML supports for strings: block scalar and flow scalar formats. (Scalars are what YAML calls basic values like numbers or strings, as opposed to complex types like arrays or objects.) Block scalars have more control ove

yaml-multiline.info


References

YAMLlint - The YAML Validator

 

YAMLlint - The YAML Validator

 

www.yamllint.com

  • yamllint
  • yaml 문법을 체크 및 결과 해석을 보여주는 사이트

https://www.json2yaml.com/

 

https://www.json2yaml.com/

JSON x

www.json2yaml.com

  • json2yaml
  • json 을 yaml로 변환해주는 사이트.

2024.01.07 - [분류 전체보기] - [Term] JSON (JavaScript Object Notation)

 

[Term] JSON (JavaScript Object Notation)

JSON (JavaScript Object Notation)은 JavaScript에서 Object Notation (객체 표기)의 목적으로 제안되었고, JavaScript 언어의 subset 임. 하지만, 오늘날 JSON은 프로그램들 간에 데이터를 교환에 사용되는 대표적인 Lig

ds31x.tistory.com

 

728x90