JSON/YAML/etc. configuration files?
What do you think of adding a JSON/YAML/etc. configuration format? I think it would make it way easier to introduce to new users.
Hi! I support this idea. We will need to implement the format converter used by vtm to JSON/YAML/etc and vice versa. Perhaps in the future one of these formats will be more convenient than the one used in vtm now. The use of vtm in its own format is due to the need to inline attribute records (for brevity) while not losing the algorithmic simplicity of merging two such configurations
<background>
<fgc>whitedk</fgc>
<bgc>blacklt</bgc>
<tile>"# \n "</tile>
</background>
the same but shorter
<background fgc=whitedk bgc=blacklt tile="# \n "/>
To convert to other serialization formats, we can translate the vtm format into some canonical form that is compatible with other formats. To do this, we need to introduce a new parameter for each attribute - _value_ - which contains the attribute's own value.
Canonical form
<background>
<_value_>""<_value_>
<fgc>
<_value_>"whitedk"<_value_>
</fgc>
<bgc>
<_value_>"blacklt"<_value_>
</bgc>
<tile>
<_value_>"# \n "<_value_>
</tile>
</background>
JSON
{
"background": {
"_value_": "",
"fgc": {
"_value_": "whitedk",
},
"bgc": {
"_value_": "blacklt",
},
"tile": {
"_value_": "# \n ",
},
},
}
YAML
- background
- _value_: ""
- fgc
- _value_: "whitedk"
- bgc
- _value_: "blacklt"
- tile
- _value_: "# \n "
~~There is also the question of how to deal with lists when merging configurations. We need a way to determine in which case the list should be overwritten and which should be added.~~
Adding an asterisk to the end of the name solves this problem for all formats.
Since xml supports multiple keys with the same name the childs would need to be stored as arrays.
Something like this would be possible:
<background >
<fgc>whitedk</fgc>
<bgc>blacklt</bgc>
<tile>"# \n "</tile>
</background>
{
"type": "backgroud",
"values": [
{
"type": "fgc",
"value": "whitedk"
},
{
"type": "bgc",
"value": "blacklt"
},
{
"type": "tile",
"value": "# \n "
}
]
}
This would also make the special syntax a bit easier.
<item* />
{
"type": "item",
"template": true
}