. yml file formats

Source: Internet
Author: User

http://yaml.org/

Yaml: Yaml Ain ' t Markup Language whatIt's: Yaml is a human friendly data serialization standard for all  p Rogramming languages.  


YAML (yet another Markup Language) (pronunciation/?jæm?l/)
A programming language used to express data sequences based on the easy-to-read Unicode, which is easy to interact with the scripting language.

Adaptation scenarios
    1. Scripting language: Because of its simplicity and low parsing costs, YAML is particularly well-suited for use in scripting languages
    2. Serialization: Yaml is a direct-to-host language data type, which is more suitable for serialization.
    3. Config file: Writing YAML is much faster than writing XML (no need to focus on tags or quotes) and is more powerful than INI documentation. Because of compatibility issues, data flow between different languages is not recommended for YAML.
YAML syntax
    1. Use spaces space to indent the hierarchy, the indentation between different levels can use a different number of spaces, but the same layer elements must be left-aligned, that is, the number of spaces preceding the same (can not use tab, the individual System tab corresponding to the number of space may be different, resulting in hierarchy confusion)
    2. ' # ' for comments, only single-line comments, from # Start to end of line
    3. A dash followed by a space (a dash and space) represents the list
    4. Use colons and spaces to denote key-value pairs Key:value
    5. Simple data (scalars, scalar data) can be enclosed in quotation marks, including string data. Used as string data in single or double quotation marks, with C-style escape characters in single or double quotes
    • Case sensitive
    • Using indents to represent hierarchical relationships
    • The TAB key is not allowed when indenting, only spaces are allowed.
    • The number of spaces you indent is not important, as long as the same level elements are left aligned

This article describes the syntax of YAML, taking the implementation of JS-YAML as an example. You can go to the online Demo to verify the example below.

YAML supports three types of data structures.

  • Object: A collection of key-value pairs, also known as mappings (mapping)/hashes (hashes)/dictionaries (dictionary)
  • Arrays: A set of sequential values, also known as sequences (sequence)/lists (list)
  • Pure weight (scalars): a single, non-divided value

These three data structures are described below.

Three, array

A set of lines at the beginning of a conjunction line that forms an array.

- Cat- Dog- Goldfish

Switch to JavaScript as follows.

[ ‘Cat‘, ‘Dog‘, ‘Goldfish‘ ]

A child member of a data structure is an array, and you can indent a space below the item.

- - Cat - Dog - Goldfish

Switch to JavaScript as follows.

[ [ ‘Cat‘, ‘Dog‘, ‘Goldfish‘ ] ]

Arrays can also be used in inline notation.

animal: [Cat, Dog]

Switch to JavaScript as follows.

{ animal: [ ‘Cat‘, ‘Dog‘ ] }

Mapping scalars to sequences simple data list key value pair

American
-Boston Red Sox
-Detroit Tigers
-New York Yankees
National
-New York Mets
-Chicago Cubs
-Atlanta Braves




. yml file formats

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.