4 ms·
I'm not a fan of rigid formats for human-entered metadata structures like config. I think it violates a kind of Postel's law .. where there ought to be consider
by sriku 6y ago
I'm not a fan of rigid formats for human-entered metadata structures like config. I think it violates a kind of Postel's law .. where there ought to be considerable flexibility for the human to specify the structure (and therefore in what the format reader accepts). If you want rigidity, just use an appropriate programming language or, say, s-expressions. The rigid formats ask for their own linters to be created and maintained.
In my indian music notation publication tool Patantara, I use a text preamble format that's limited and far simpler for people to use than any of these "data structure capable" formats - including NestedText/YAML/JSON. Here is a quick description -
1. You specify key value pairs with lines of the form -
key with allowed spaces = any textual value
2. The first " = " on a line separates the key from the value. The key is normalized to lower case and spaces in the key are normalized to single space, and the key is LR-trimmed. The textual value is mostly kept as is (except for LR-trimming), but can accumulate more content.
3. Lines which don't have a " = " are just strings that get appended to the value of the immediately preceding key. So
key = value1
value2
value3
will result in the key "key" having the single string value "value1\nvalue2\nvalue3".
4. If the same key is given multiple times, the values are concatenated with line breaks. So
key = value1
key = value2
key = value3
gets you, for the key "key", the value "value1\nvalue2\nvalue3".
5. The reader doesn't care about data types. However, the application can decide how to parse the string values. One convenience I use for lists of items is "comma or whitespace separated values", where a list of values is given as "value1, value2, value3" or "value1\nvalue2\nvalue3" or "value1 value2 value3" or any combination including "value1, value2,\nvalue3 value4".
Nested structure is not possible with this format (unless you impose more structure on the value in the application), but it serves very well as a metadata format for text files in my application.
Ref: https://blog.patantara.com/blog/2017/04/16/controlling-who-can-view/edit-your-document/ https://blog.patantara.com/blog/2017/04/16/controlling-who-c...