3 ms·
I'm on my phone right now but maybe one if you can double check: since YAML is a superset of JSON you can parse JSON with a YAML parser right? Does that mean yo
by winrid 4y ago
I'm on my phone right now but maybe one if you can double check: since YAML is a superset of JSON you can parse JSON with a YAML parser right? Does that mean you can add YAML comments to JSON and parse the JSON with the YAML parser, to get JSON-with-comments?
- deleted 4y ago[deleted]
- samus 4y agoShould work, but various JSON parsers (Jackson for sure) can be configured to also deal with (JS-style) comments. If all you will realistically have to process is JSON+comments, I'd stick to a parser that does just that. Also, YAML has more features, and YAML parsers have to be a whole lot more complicated as a result. This is important if you use that parser at a security boundary!
- formerly_proven 4y agoIn hindsight, defining JSON as a subset of JS syntax without comments is the by far biggest design flaw of JSON, in particular because JS comments are very easy to parse.
- winrid 4y agoJSON was meant as a human readable communication protocol, not for configuration files.
- ungawatkt 4y agoThe last I remember thinking about that idea, the answer was yes. And that I could probably switch out the parser to a yml parser, not tell anyone, and get a few months free of parsing errors in our hand written json (don't ask) before anyone noticed. But then I imagined dealing with the inevitable yml parse errors when people figured out the new constraints, and decided not to take that particular path to code sins. I can't remember if I actually tested it for real though.
- rocqua 4y ago> But then I imagined dealing with the inevitable yml parse errors when people figured out the new constraints This all sounded like a good idea until I read this. Now I too shudder with fear.