Re: XML<-> JSON conversion. What do you think?
- From: Max <adsl@xxxxxxxxxx>
- Date: Sun, 10 Aug 2008 15:39:28 +0200
Lasse Reichstein Nielsen ha scritto:
Not really. It shows that a particularly naïve implementation
of a conversion from XML to JSON doesn't work well.
Really, then most of implementations of conversion from XML to JSON are naïve!
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?
For JSON, "textual" is a value of "a" and then { a: "textual" }.
This convertion is your expansive implementation created to bypass the JSON limitations...
In fact, to obtain the string "some" instead of (example) e["#text"], you must use a blinded mode tag.content[1], while it is more correct to log on with the real name of the object/tag, that is "e"!
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
Can you suggests to me a good XML-JSON converter?
.
- Follow-Ups:
- Re: XML<-> JSON conversion. What do you think?
- From: Lasse Reichstein Nielsen
- Re: XML<-> JSON conversion. What do you think?
- From: Thomas 'PointedEars' Lahn
- Re: XML<-> JSON conversion. What do you think?
- References:
- XML<-> JSON conversion. What do you think?
- From: Max
- Re: XML<-> JSON conversion. What do you think?
- From: Thomas 'PointedEars' Lahn
- Re: XML<-> JSON conversion. What do you think?
- From: Max
- Re: XML<-> JSON conversion. What do you think?
- From: Thomas 'PointedEars' Lahn
- Re: XML<-> JSON conversion. What do you think?
- From: Max
- Re: XML<-> JSON conversion. What do you think?
- From: Lasse Reichstein Nielsen
- XML<-> JSON conversion. What do you think?
- Prev by Date: Re: FAQ Suggestion
- Next by Date: Re: XML<-> JSON conversion. What do you think?
- Previous by thread: Re: XML<-> JSON conversion. What do you think?
- Next by thread: Re: XML<-> JSON conversion. What do you think?
- Index(es):
Relevant Pages
|