yaml 性能测试?前言,我来给大家讲讲关于yaml的科普 性能测试?希望下面有你想要的答案。让我们看看!
yaml 性能测试
前言
YAML 是 "yaml Ain't a Markup Language"(YAML 递归缩写不是一种标记语言)。在开发这种语言时,YAML 其实意思是:"Yet Another Markup Language"(仍然是标记语言)。
YAML 语法类似于其他高级语言,可以简单地表达数据形式,如清单、散列表、标量等。它采用空白符号缩进和大量依赖外观的特点,特别适合表达或编辑数据结构、各种配置文件、倾斜调试内容和文件大纲(例如,许多电子邮件的标题格式非常接近YAML)。
YAML 配置文件的后缀是 .yml,如:ansible-playbook.yml,Hexo的配置文件也是_config.yml
更新历史
2020年01月09日 – 初稿
阅读原文 – https://wsgzao.github.io/post/yaml/
扩展阅读
YAML
YAML简介
YAML: YAML Ain't Markup Language
What It Is: YAML is a human friendly data serialization standard for all programming languages.
YAML 语言(发音 /ˈjæməl/ )设计目标,方便人类读写。它本质上是一种通用的数据串行格式。它本质上是一种通用的数据串行格式。
其基本语法规则如下。
大小写敏感
使用缩进表示层级关系
Tab键不允许缩进,只允许使用空间。
缩进的空间数量并不重要,只要左侧对齐相同层次的元素
# 表示注释,从这个字符到行尾,都会被分析器忽略。
YAML 有三种数据结构支持。
对象:键值对的集合,又称映射(mapping)/ 哈希(hashes) / 字典(dictionary)
数组:一组按顺序排列的值,又称为序列(sequence) / 列表(list)
纯量(scalars):单个、不可分割的值
X分钟快成Y
其中 Y=yaml
下载源代码: learnyaml-cn.yaml
YAML 设计成人类直接可写可读的数据序列语言。
它是 JSON 严格的超集增加了显著的语法换行符和缩进,就像 Python。
它是 JSON 严格的超集增加了显著的语法换行符和缩进,就像 Python。但和 Python 不一样, YAML 文字制表符根本不允许。
# YAML 注释看起来像这样。
################
# 标量类型 #
################
# 根对象 (它们在整个文件中延续) 它将是一个映射,
# 它等同于其他语言中的字典、哈希表或对象。
key: value
Another_key: Another value goes here.
a_number_value: 100
# 数字 1 它将被解释为数值,而不是布尔值。
# 如果你想要一个布尔值,使用它 true。
scientific_notation: 1e 12
boolean: true
null_value: null
key with spaces: value
# 请注意,引号中不需要包含字符串,但也可以包含字符串。
however: 'A string, enclosed in quotes.'
'Keys can be quoted too.': "Useful if you want to put a ':' in your key."
single quotes: 'have ''one'' escape pattern'
double quotes: "have many: \", \0, \t, \u263A, \x0d\x0a == \r\n, and more."
# UTF-8/16/32 字符需要转义(encoded)
Superscript two: \u00B2
# 多行字符串可以写成'文字块'(使用 |),
# 或者像'折叠块'(使用 '>')。
literal_block: |
This entire block of text will be the value of the 'literal_block' key,
with line breaks being preserved.
The literal continues until de-dented, and the leading indentation is
stripped.
Any lines that are 'more-indented' keep the rest of their indentation –
these lines will be indented by 4 spaces.
folded_style: >
This entire block of text will be the value of 'folded_style', but this
time, all newlines will be replaced with a single space.
Blank lines, like above, are converted to a newline character.
'More-indented' lines keep their newlines, too –
this text will appear over two lines.
####################
# 集合类型 #
####################
# 嵌套是通过缩进完成的。推荐使用 2 缩进一个空间(但不必要)
a_nested_map:
key: value
another_key: Another Value
another_nested_map:
hello: hello
# 映射键不必是字符串。
0.25: a float key
# 键也可以复合,如多行对象
# 我们用 ?
0.25: a float key
# 键也可以复合,如多行对象
# 我们用 ? 用一个空间来表示复合键的开始。
? |
This is a key
that has multiple lines
: and this is its value
# YAML 序列之间的映射关系也可以用复杂的键语法来表示。
# 但是有些语言的解析器可能不支持。
# 一个例子:
? – Manchester United
– Real Madrid
: [ 2001-01-01, 2002-02-02 ]
# 序列 (等于列表或数组) 看上去像这样:
# 注意 '-' 算作缩进
a_sequence:
– Item 1
– Item 2
– 0.5 # 可包含不同类型的序列。
– Item 4
– key: value
another_key: another_value
–
– This is a sequence
– inside another sequence
– – – Nested sequence indicators
– can be collapsed
# 因为 YAML 是 JSON 的超集,你也可以写 JSON 风格的映射和序列:
json_map: {"key": "value"}
json_seq: [3, 2, 1, "takeoff"]
and quotes are optional: {key: [3, 2, 1, takeoff]}
#######################
# 其余的 YAML 特性 #
#######################
# YAML 还有一个方便的特点叫做 '锚',它可以让你很容易地在文档中重用文本。
# 以下两个键具有相同的值:
anchored_content: &anchor_name This string will appear as the value of two keys.
other_anchor: *anchor_name
# 锚也可用于复制/继承属性
base: &base
name: Everyone has same name
# The regexp << is called Merge Key Language-Independent Type.
# 它表明指定映射的所有键都将插入当前映射。
foo: &foo
<<: *base
age: 10
bar: &bar
<<: *base
age: 20
# foo 和 bar 将都含有 name: Everyone has same name
# YAML 还有标签,你可以用它来显示类型。
explicit_string: !
explicit_string: !!str 0.5
# 一些解析器实现了特定语言的标签,就像这样 Python 复数类型。
python_complex_number: !!python/complex 1 2j
# 我们也可以 YAML 在复合键中使用特定语言的标签
? !!python/tuple [5, 7]
: Fifty Seven
# 将会是 Python 中的 {(5, 7): 'Fifty Seven'}
####################
# 其余的 YAML 类型 #
####################
# 除字符串和数字外,YAML 其它标量也可以理解。
# ISO 也可以分析格式的日期和日期时间文本。
# ISO 也可以分析格式的日期和日期时间文本。
datetime: 2001-12-15T02:59:43.1Z
datetime_with_spaces: 2001-12-14 21:59:43.10 -5
date: 2002-12-14
# 这个 !!binary 标签表示字符串实际上是这个字符串
# 是一个用 base64 二进制代码表示 blob。
gif_file: !!binary |
R0lGODlhDAAMAIQAAP//9/X17unp5WZmzgAAAOfn515exvpz7ojudg4 fn5
OTK6enp56enmlpawny6ojo4SEhp/ f/ f/ f/ f/ f/ f/ f/ f/
f/ f/ f/ f/ f/ SH DK1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
Agjoewnunafohpetrgcz4BNJHrv/ZCFcLiwMWYNG84BwEECgoBADsGoBADs=
# YAML 还有一种集合类型,它看起来像这样:
set:
? item1
? item1
? item2
? item3
or: {item1, item2, item3}
# 集合只是值 null 映射;上述集合等于:
set2:
item1: null
item2: null
item3: null
… # document end
参考文章
YAML official website
Online YAML Validator
X分钟快成Y
YAML 入门教程,