Blocks
Blocks are the main structure providers of KyoML, they translate to JSON Objects. They are a named collection of key/value pairs.
[Note] The root of the document is a block itself |
Example
KyoML | JSON |
foo = "bar"
world {
greeting = "hello"
}
|
{
"foo": "bar",
"world": {
"greeting": "hello"
}
}
|
Difference between Blocks and Maps
When translated to JSON, both Blocks
and Maps
become plain objects, they however differ in the following ways:
Blocks
- designed as a structural construct
- support @directives at their root
- cannot be piped
- tolerant syntax (commas are optional)
Example
block {
@directive
key = "value"
key2 = "value2"
}
Maps
- designed as a value
- strict syntax (mandatory commas, keys are strings)
- do not support @directives at their root
- can be piped
Example
map = {
"key": "value",
"key2": "value2"
}
Nested Blocks
Example
KyoML | JSON |
foo = "bar"
world {
name = "earth"
greeting {
word = "hello"
kind = "pleasant"
rating = 5
}
}
|
{
"foo": "bar",
"world": {
"name": "earth",
"greeting": {
"word": "hello",
"kind": "pleasant",
"rating": 5
}
}
}
|