Logo for JSON

To be filed under “shoulda-woulda-coulda” and “no-shit-sherlock” and also “forgot-to-write-about-this-fifteen-years-ago”…

I have had to think about XML for the first time in a few years (for the curious, you can read this EPUB bug I filed). If XML had had an array type for simple values (strings), then instead of representing a list of values like this:

<topLevel>
  <myList>
    <item value="abc" />
    <item value="def" />
    <item value="ghi" />
  </myList>
</topLevel>

It could have been this:

<topLevel myList=["abc", "def", "ghi"] />

Would folks have abandoned XML for JSON so quickly?

§1210 · January 11, 2020 · Software, Technology, Web, XML · Tags: , · [Print]

1 Comment to “XML Needed an Array Type”

  1. John Bilicki says:

    A post! I really dislike JSON’s reliance on strictly using double quotes, mainly because PHP uses them to interpret variables in echo statements so I stick to single quotes in JavaScript and PHP which plays nicely with HTML using double quotes. So when I need to store JSON in an input or a data-* attribute I first have to use something like encodeURI() though Douglas Crockford started with FORTRAN and I’d imagine his interpretation on quote usage is likely different.

    Presuming my take on quotes in programming languages isn’t in the minority I’d have the JSON standard fixed and use something along the lines of:


    <top_level my_list="['a' => 1, 'd' => 'n7', 'ghi']" />

    XML is a pain as a dedicated interchangeable format (from a PHP perspective) though I love how browser rendering engines are very strict with it versus the absolute garbage that HTML parsers allow (or just outright ignore). My system is still using XML parsers and will likely do so until something stricter and more useful comes along (if ever). JSON is much easier to work with as an interchangeable format even if the quote requirement is backwards.

    I think the most pragmatic fix for JSON would be to allow either single or double quotes though ALL quotes MUST be of the same type for each full JSON source.

    Funny you posted about the order not being honored in that bug. I always list HTML attributes alphabetically though someone thought it’d be cute to change Gecko or at least the developer tools to move the id and type attributes around which is a pain for Rich Editing. Changing the order of HTTP POST inputs could allow for extremely strict server validation of a form before parsing too, no one should be messing with that kind of stuff; it serves no logical purpose, creates variation between user agents, eliminates natural inclination of evolution of programming and is an overall waste of resources that could be better spent elsewhere.

Leave a Reply