News for hackers. Stuff that matters.
Re:Ask HN: If Kubernetes is the solution, why are there so m... by rustyminnow on Wednesday June 01, 2022 @12:49PM (#31584602)
Technically YAML is a superset of JSON - all valid JSON is valid YAML. So you could write all your configs in JSON and they'd work just fine.
Re:Ask HN: If Kubernetes is the solution, why are there so m... by krapp on Wednesday June 01, 2022 @01:07PM (#31584879)
This discussion from a couple of weeks ago suggests it isn't that simple: not all valid JSON is always valid YAML if your definition of superset requires that JSON would be parsed the same with a YAML parser as with a JSON parser.

If you're going to use JSON for config, it's better to use an actual JSON parser.

https://john-millikin.com/json-is-not-a-yaml-subset https://news.ycombinator.com/item?id=31406473

Re:Ask HN: If Kubernetes is the solution, why are there so m... by rustyminnow on Wednesday June 01, 2022 @01:22PM (#31585096)
Thanks! That's really interesting.

You could mitigate some of the issues and get JSONs "strictness as a feature" by passing the document through e.g. `jq . $file` as a CI step, but I don't think that'd resolve the 1e2 issue. TBH I didn't know you could write numbers in JSON like that, so I imagine it'd be an issue that doesn't come up often. But it's disappointing that it wouldn't just work.

Re:Ask HN: If Kubernetes is the solution, why are there so m... by bmn__ on Wednesday June 01, 2022 @02:18PM (#31585908)
> Technically YAML is a superset of JSON

That's false. http://p3rl.org/JSON::XS#JSON-and-YAML

Re:Ask HN: If Kubernetes is the solution, why are there so m... by rustyminnow on Wednesday June 01, 2022 @06:31PM (#31588982)
I'd like to amend my statement:

Technically YAML is (supposed to be) a superset of JSON - (almost) all valid JSON is valid YAML. So you could write all your configs in JSON and they'd (probably) work just fine (assuming you keep things relatively simple).