A common configuration file format (yaml, ini)

YAML format

  • File name suffix is ​​usually .yml

  • YAML is a superset of JSON, means that any valid JSON file is also a valid YAML file

  • More YAML configuration file can be the same in

    • Use ---indicates the beginning of a document
    • In a file, which can contain a plurality of files, and by ---the partition
    • ...And ---with the use, mean the end of a file in a configuration file
  • Case Sensitive

  • # It indicates a comment

  • indentation

    • Not allowed to use the Tab key to indent only allows the use of space
    • The number of spaces to indent does not matter, as long as the left elements are aligned to the same level
  • Supported data types

    • Objects
      • It represents a set of key-value pairs, colon structure
    • Array
      • -Beginning of the line to form an array
    • Scalar
      • String, Boolean, integer, floating point, NULL, time, date
        • NULL with ~representation
        • String Default does not use quotation marks
          • Contain spaces or special characters, needs to be placed in quotation marks
boolean: 
    - TRUE  #true,True都可以
    - FALSE  #false,False都可以
float:
    - 3.14
    - 6.8523015e+5  #可以使用科学计数法
int:
    - 123
    - 0b1010_0111_0100_1010_1110    #二进制表示
null:
    nodeName: 'node'
    parent: ~  #使用~表示null
string:
    - 哈哈
    - 'Hello world'  #可以使用双引号或者单引号包裹特殊字符
    - newline
      newline2    #字符串可以拆成多行,每一行会被转化成一个空格
date:
    - 2018-02-17    #日期必须使用ISO 8601格式,即yyyy-MM-dd
datetime: 
    -  2018-02-17T15:02:31+08:00    #时间使用ISO 8601格式,时间和日期之间使用T连接,最后使用+代表时区

reference

ymal Started - rookie Tutorial

ymal Quick Start

INI format

  • INI file extension is not necessarily the ".ini", may be ".cfg", ". Conf", etc.

  • ini file is composed of several section, each section in turn composed of a plurality of parameters

    • parameters format:name = key
    • section format:[section]
    • Notes format:;
Published 161 original articles · won praise 19 · views 50000 +

Guess you like

Origin blog.csdn.net/winter_wu_1998/article/details/103469213