Using variables, also called repeated nodes in YAML, but in JSON variant of YAML format. I'm using this for the whole subtree. Great!
{
"original": &VAR
{
"x": "Value x",
"subtree":
{
"y": "Value Y"
}
},
"copy": *VAR
}
Enter this in online YAML parser and you will see the light.
Also, this is fuckingly awesome! YAML merge key, but in JSON format. Again, put it in an online parser.
{
"common": &COMMON
{
"username": "portly",
"adapter": "mysql",
"password": "666HELL666",
"host": "localhost",
"database": "rails_dev"
},
"production": *COMMON,
"testing": *COMMON,
"custom":
{
<<: *COMMON,
"username": "CHANGED FROM COMMON"
}
}
You can also do this, often usable for default values:
{
<<: { "username": "Default value" },
"username": "New value"
}
Note that the last one doesn't work on Ruby parser. But the following stuff does, and obeys the order of execution:
{
"dummy": &DEFAULT
{
"username": "Default value"
},
<<: *DEFAULT,
"username": "New value"
}
I love you YAML