News for hackers. Stuff that matters.
Re:XML is better than YAML by dekelpilli on Thursday September 21, 2023 @01:48AM (#37593668)
It is, as it should be. I'm struggling to format it nicely here in HN, but I believe that the formatting show here [0] is more readable than JSON or YAML. It gives you type flexibility (instead of JSON's string-only keys). What's the source of your confusion here?

[0] https://github.com/bbatsov/clojure-style-guide#opt-commas-in...

Re:XML is better than YAML by mkl on Thursday September 21, 2023 @03:40AM (#37594398)
The confusion is that the order of the key and value can be reversed, and commas are optional, so there's no way to tell at a glance what e.g. the value associated with:bar is.
Re:XML is better than YAML by eduction on Thursday September 21, 2023 @12:43PM (#37600288)
>the order of the key and value can be reversed

This is the case with any hash-map in any language, modulo some of them making certain keys illegal.

But "string":"string" can be reversed in pretty much any language's hash-map.

>here's no way to tell at a glance what e.g. the value associated with:bar is.

You've certainly constructed and formatted a hash-map that is a little tricky to understand, but 1> this combination of key and value types is going to be pretty rare in the wild and 2> to the extent it exists, people would format it to be easier to parse, either by adding commas or newlines.

Re:XML is better than YAML by dekelpilli on Saturday September 23, 2023 @08:45AM (#37622766)
> the order of the key and value can be reversed

That's not true. What you're seeing here is a map where [1 2 3] is the key for the value :baz

Re:XML is better than YAML by roryokane on Thursday September 21, 2023 @05:26PM (#37604607)
Fixed link to that style guide entry: https://guide.clojure.style/#opt-commas-in-map-literals

Per that style guide, the above map should be formatted like this:

  {:a 1
   2 :bar
   [1 2 3] :baz}
Most maps written in EDN have keys of a consistent type. A map whose keys are consistently keywords would look like this when formatted:

  {:a [1 2]
   :bar "https://example.com/"
   :baz [1 2 3]}
HN comment formatting help: https://news.ycombinator.com/formatdoc. I indented the above code by two spaces.