Re:YAML: probably not so great after all (2017)
by EamonnMR on Wednesday June 20, 2018 @06:10PM
(#17360288)
> you can use a simple, JSON-like language with comments for config.
YAML can be employed as a simple JSON-like language with comments.
Re:YAML: probably not so great after all (2017)
by crooked-v on Wednesday June 20, 2018 @06:15PM
(#17360325)
> simple
YAML is much, much more complicated than JSON.
Re:YAML: probably not so great after all (2017)
by hk__2 on Wednesday June 20, 2018 @06:39PM
(#17360503)
> simple
YAML is much, much more complicated than JSON.
Quoting a single word from the parent’s sentence is misleading. The sentence "YAML can be employed as a simple JSON-like language with comments." is true because JSON is YAML, so you can parse a JSON file with #-comments using a YAML parser.
Re:YAML: probably not so great after all (2017)
by skybrian on Wednesday June 20, 2018 @07:32PM
(#17360847)
The parser is not simple, though, and that's what counts.
Re:YAML: probably not so great after all (2017)
by bdhess on Wednesday June 20, 2018 @08:41PM
(#17361156)
Most YAML users don't need to look at the source for a YAML parser. I appreciate elegant simplicity, but I don't think parser complexity is the most important metric by which to judge a data interchange format.
Re:YAML: probably not so great after all (2017)
by skybrian on Thursday June 21, 2018 @01:46AM
(#17362445)
If you use a YAML parser to parse JSON-with-comments, it will accept many inputs that don't correspond to JSON-with-comments, and furthermore is likely to report syntax errors that don't make sense to a user who only knows JSON.
So, this unnecessary parser complexity is a usability issue. You should use a parser for the config language you actually intend to support.
Re:YAML: probably not so great after all (2017)
by spankalee on Wednesday June 20, 2018 @08:16PM
(#17361072)
JSON5 is also a great alternative: https://json5.org/
Supports comments, trailing commas, single quotes, multi-line strings, and more number formats.
Re:YAML: probably not so great after all (2017)
by nojvek on Wednesday June 20, 2018 @10:52PM
(#17361714)
I really wished json5 would support optional commas as well. If you have a new line, no comma needed. So you can do
[
1
2
3
]
New lines used by humans, computers should do a good job as well.
Re:YAML: probably not so great after all (2017)
by adamkruszewski on Thursday June 21, 2018 @07:30AM
(#17364049)
It looks very like an s-expression. Maybe we should go back to Lisp for our data encoding? (and to our code when we are at it? ;))
Re:YAML: probably not so great after all (2017)
by Sean1708 on Thursday June 21, 2018 @09:09AM
(#17364696)
Like https://hjson.org/?
Re:YAML: probably not so great after all (2017)
by spiralx on Friday June 22, 2018 @12:43PM
(#17375397)
Well you could use CSON, which uses CoffeeScript notation that allows for constructs such as:
required: [
'firstName'
'lastName'
]which is the same as:
{
"required": [
"firstName",
"lastName"
]
}in JSON :)
Technically, this is not JSON. You won't be able to use a standard JSON parser without stripping comments first. But you can use a simple, JSON-like language with comments for config.
[1] https://code.visualstudio.com/docs/languages/json#_json-with...