Sean Catchpole wrote:
I really like json, and the ability to recognize arrays is great.
However, there is strength of xml in that order can be preserved. I
can not think of a way to implement this in json. Is it possible and I
am simply blind to the truth?

XML:
<p><b>Title</b><i>Subtitle</i><b>Author</b></p>

JSON:
{"p":{"b":["Title","Author"],"i":"Subtitle"}}

I don't really understand what this would be for. JSON is meant for structured data. XML is meant as a markup language and specifically good for those cases where structured data doesn't really fit. Granted, XML can also represent structured data, but the advantage that JSON has over XML is only that it uses less cruft to define structured data. Trying to use if for unstructured markup is... odd.

That said, would this do what you want?:

    {"p": [{"b": "Title"}, {"i": "Subtitle"}, {"b": "Author"}]}

or to represent more complex mixed content such as

    <p>This <a href="a.html"><b>powerful</b> link</a> goes nowhere!</p>

we might use

{"p": ["This ", {"a" : {"href": "a.html", "_": [{"b": "powerful"}, " link"]}}, " goes nowhere!"]}

I'm not sure what it would be good for, though.

  -- Scott

Reply via email to