summaryrefslogtreecommitdiffhomepage
path: root/yaml.html.markdown
diff options
context:
space:
mode:
authorSuzane Sant Ana <tetestonaldo@gmail.com>2017-12-31 14:27:06 -0200
committerGitHub <noreply@github.com>2017-12-31 14:27:06 -0200
commit42f9329bb3a028d374d6397991ac48b44064741e (patch)
tree1e75e2b3e122aeb863e3ffa037f6f64c4027fbf8 /yaml.html.markdown
parente6b77595f2669d66ac7be43c6e6083cbff80a9a7 (diff)
parent70a36c9bd970b928adde06afb2bd69f6ba8e5d5c (diff)
Merge pull request #1 from adambard/master
update
Diffstat (limited to 'yaml.html.markdown')
-rw-r--r--yaml.html.markdown38
1 files changed, 35 insertions, 3 deletions
diff --git a/yaml.html.markdown b/yaml.html.markdown
index 6e3e2c94..3b32a069 100644
--- a/yaml.html.markdown
+++ b/yaml.html.markdown
@@ -3,6 +3,7 @@ language: yaml
filename: learnyaml.yaml
contributors:
- ["Adam Brenecki", "https://github.com/adambrenecki"]
+ - ["Suhas SG", "https://github.com/jargnar"]
---
YAML is a data serialisation language designed to be directly writable and
@@ -25,6 +26,8 @@ key: value
another_key: Another value goes here.
a_number_value: 100
scientific_notation: 1e+12
+# The number 1 will be interpreted as a number, not a boolean. if you want
+# it to be interpreted as a boolean, use true
boolean: true
null_value: null
key with spaces: value
@@ -66,14 +69,19 @@ a_nested_map:
# Maps don't have to have string keys.
0.25: a float key
-# Keys can also be multi-line objects, using ? to indicate the start of a key.
+# Keys can also be complex, like multi-line objects
+# We use ? followed by a space to indicate the start of a complex key.
? |
This is a key
that has multiple lines
: and this is its value
-# YAML also allows collection types in keys, but many programming languages
-# will complain.
+# YAML also allows mapping between sequences with the complex key syntax
+# Some language parsers might complain
+# An example
+? - Manchester United
+ - Real Madrid
+: [ 2001-01-01, 2002-02-02 ]
# Sequences (equivalent to lists or arrays) look like this:
a_sequence:
@@ -101,12 +109,31 @@ json_seq: [3, 2, 1, "takeoff"]
anchored_content: &anchor_name This string will appear as the value of two keys.
other_anchor: *anchor_name
+# Anchors can be used to duplicate/inherit properties
+base: &base
+ name: Everyone has same name
+
+foo: &foo
+ <<: *base
+ age: 10
+
+bar: &bar
+ <<: *base
+ age: 20
+
+# foo and bar would also have name: Everyone has same name
+
# YAML also has tags, which you can use to explicitly declare types.
explicit_string: !!str 0.5
# Some parsers implement language specific tags, like this one for Python's
# complex number type.
python_complex_number: !!python/complex 1+2j
+# We can also use yaml complex keys with language specific tags
+? !!python/tuple [5, 7]
+: Fifty Seven
+# Would be {(5, 7): 'Fifty Seven'} in Python
+
####################
# EXTRA YAML TYPES #
####################
@@ -137,3 +164,8 @@ set2:
item2: null
item3: null
```
+
+### More Resources
+
++ [YAML official website](http://yaml.org/)
++ [Online YAML Validator](http://codebeautify.org/yaml-validator)