3 ms·
> ... JSON is a legal subset of yaml ... True in a sense, but false in a more important one. JSON removes the syntactic dependence on whitespace -- one can par
by lutusp 13y ago
> ... JSON is a legal subset of yaml ...
True in a sense, but false in a more important one. JSON removes the syntactic dependence on whitespace -- one can parse JSON unambiguously while ignoring the whitespace that separates sections, relying only on explicit delimiters:
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
This makes JSON a superset of YAML, not a subset. JSON has properties that YAML doesn't, properties that remove the ambiguity in YAML's syntax, properties that answer my original objection.
> so if you want to use a more well defined format, you can.
Indeed, I agree. It's true because JSON corrects the primary defect in YAML. YAML was originally designed to be terse and human-readable and -editable, but at the cost of syntactic ambiguity when scanned. JSON solves the problem by reintroducing the delimiters that YAML removed.