Re: XML<-> JSON conversion. What do you think?



Max <adsl@xxxxxxxxxx> writes:

These cases demonstrates the difference between JSON and XML.

Not really. It shows that a particularly naïve implementation
of a conversion from XML to JSON doesn't work well.


What if the conversion of
<e>
some
<a>textual</a>
content
</e>

was:

{"tag": "e",
"content" : [ "some",
{"tag": "a", "content": ["textual"]}
"content" ]}

What is the big difference then?

I think
to use JSON to transmit simples data and XML for structured data.

Your choice. Neither is inherently better (although JSON is often
shorter), but their performances depend on the choice of encoding
as much as the format of the data.

XML only has raw text and elements nodes. Element nodes both work as a
list of XML nodes and as a map from strings to strings (attributes),
and it has a type itself (the tag name). Everything is rolled into
this one compound construct.

JSON has two types of compound structures: (unordered) Maps and
(ordered) Lists (i.e., indexed by either name or by number).

In that sense, JSON is richer than XML, where name-indexed attributes
can only contain simple text.

I find that most data can be well represented in JSON, but starting
with XML data obviously makes JSON look worse than XML. Just as starting
with JSON data would probably make XML look worse.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
.



Relevant Pages

  • Re: XML<-> JSON conversion. What do you think?
    ... JSON limitations... ... JSON is not XML. ... Converting one to the other literally will ... var attrs = node.attributes; ...
    (comp.lang.javascript)
  • XML<-> JSON conversion. What do you think?
    ... According to Stefan Goessner, to obtain a correct conversion from XML to JSON it must apply some patterns to maintain order and structure of the elements. ...
    (comp.lang.javascript)
  • Re: More bollocks from biggots
    ... The paper don't say that the best workaround is to use a XML ... A server can mount a defense against JavaScript Hijacking by responding ... on adding support for JSON in future versions. ...
    (comp.os.vms)
  • Re: XML<-> JSON conversion. What do you think?
    ... then most of implementations of conversion from XML to JSON are naïve! ...
    (comp.lang.javascript)
  • Re: New to JSON
    ... is writing an XML to JSON converter. ... and provide JSON to newer applications. ... This was a snippet of an auto-generated output from this converter. ...
    (microsoft.public.scripting.jscript)