I'd like to use a configuration file format which supports key value pairs and nestable, repeatable structures, and which is as light on syntax as possible. I'm imagining something along the lines of:
cachedir = /var/cache
mail_to = me@example.org
job {
name = my-media
frequency = 1 day
source {
from = /home/michael/Images
source { }
source { }
}
job { }
I'd be happy with something using significant-whitespace as well.
JSON requires too many explicit syntax rules (quoting, commas, etc.). YAML is actually pretty good, but would require the jobs to be defined as a YAML list, which I find slightly awkward to use.
解决方案
I think YAML is great for this purpose, actually:
jobs:
- name: my-media
...
- name: something else
...
Or, as a dict instead of list:
jobs:
my-media:
frequency: 1 day
...
something-else:
frequency: 2 day
...
Another thing to consider, which you might not have, is using Python source for the configuration. You can nest Python dicts and lists in a very readable manner and it provides multiple unexpected benefits. Django uses Python source for its settings files, for example.