[OT] is JSON all that great? - was Re: API Help

Marko Rauhamaa marko at pacujo.net
Thu Jun 15 01:10:26 EDT 2017


Chris Angelico <rosuav at gmail.com>:

> XML is thus poorly suited to *most* forms of data,

Correct.

> <?xml version="1.0" encoding="UTF-8" ?>
> <spam>
>   <asdf>aa</asdf>
>   <qwer>qq</qwer>
>   <qwer>qw</qwer>
>   <qwer>qe</qwer>
>   <asdf>as</asdf>
> </spam>
>
> What does this represent? A generic XML parser has to cope with it. I
> gave this to a few XML-to-JSON converters, and they all interpreted it
> as some variant of {"asdf":["aa","as"],"qwer":["qq","qw","qe"]}

It's worse than that. For a *generic* parser, it should be something
like:

   {
       "spam" : [
           "  \n",
           { "asdf" : [ "aa" ] },
           "  \n",
           { "qwer" : [ "qq" ] },
           "  \n",
           { "qwer" : [ "qw" ] },
           "  \n",
           { "qwer" : [ "qe" ] },
           "  \n",
           { "asdf" : [ "as" ] },
           "\n"
       ]
   }

> XML just needs to die.

Thankfully, that seems to be happening.


Marko



More information about the Python-list mailing list