Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree. YAML is hell. XML is just completely misunderstood.

This one bit me recently. Parse it and see what happens.

  - yaml: 
    - 01
    - 08
This one works as expected:

  <list>
    <value>01</value>
    <value>08</value>
  </list>
And I can qualify it

  <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="list">
      <xs:complexType>
        <xs:sequence>
          <xs:element type="xs:string" name="value" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:schema>


Ok but, just like the author of that article, you're just using the wrong datatype... You can easily get the desired behavior by quoting the strings:

    - yaml:
      - '01'
      - '08'
Complaining about this is like complaining that

    { json: [01, 08] }
will be interpreted as [1, 8] in json... It's not a problem with the tool, it's a user error.


It’s not just user error – it’s a problem with the YAML format and culture. The YAML format allows most strings to be written without quotes. And YAML culture, as communicated through most YAML snippets in documentation and YAML files in the wild, is to take advantage of this by only adding quotes when necessary. That makes certain categories of user error much more likely. Someone might write `09` and confirm it’s a string, then change `9` to `7` and not notice that their string has turned into a number.

The JSON format avoids this problem because it requires that all strings be quoted. If you start with `["09", "08"]` and change one of the digits inside the quotes, the string will stay a string. In JSON, strings becoming not-strings – removal of quotes or addition of backslash escaping – is more obvious than in YAML.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: