473,883 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Max <ad**@tiscali.i twrites:
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/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Aug 10 '08 #1
6 2836
Max
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?
Aug 10 '08 #2
Max wrote:
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!
It would seem you are not exactly in a position to make a correct assessment.
>What if the conversion of <esome <a>textual</acontent </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"
Nonsense.
and then { a: "textual" }.
And if there was

{ a: "textual", b: "foo" }

you could not know which one came first.
This convertion is your expansive implementation created to bypass the
JSON limitations...
There are no limitations in JSON but those you make up here.
In fact, to obtain the string "some" instead of (example) e["#text"], you
must use a blinded mode tag.content[1],
Not necessarily. As the DOM provides getElementsByTa gName(), a similar
method can be implemented to traverse the object created from parsing JSON.
while it is more correct to log on with the real name of the object/tag,
that is "e"!
You are mistaken. Text child nodes of the same level do not belong together
unless they are adjacent. Your approach would allow for one text child node
per element only.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>
Aug 10 '08 #3
Max
Thomas 'PointedEars' Lahn ha scritto:
Max wrote:
>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!

It would seem you are not exactly in a position to make a correct assessment.
Why? I'm talking about proper implementation of a XML2JSON converter.
I say that then most of converters are naïve because I find many
converters that make a simple conversion from JSON.
At the same json.org website there are examples of simple conversion
(http://www.json.org/example.html)!
I have raised doubts and asked a question:
"Can you suggests to me a good XML-JSON converter?"
I have not received any answer, but only chats.

Max
Aug 11 '08 #4
Max wrote:
Thomas 'PointedEars' Lahn ha scritto:
>Max wrote:
>>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!
It would seem you are not exactly in a position to make a correct
assessment.

Why? I'm talking about proper implementation of a XML2JSON converter. I
say that then most of converters are naïve because I find many converters
that make a simple conversion from JSON. At the same json.org website
there are examples of simple conversion
(http://www.json.org/example.html)! I have raised doubts and asked a
question: "Can you suggests to me a good XML-JSON converter?" I have not
received any answer, but only chats.
You have received several answers addressing your question while we have
been engaging in a technical discussion about what would make up a good
converter. Whether you like that or not is a different matter, and how to
use search engines is beyond the scope of this newsgroup.

<http://jibbering.com/faq/>
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Aug 11 '08 #5
Max
Thomas 'PointedEars' Lahn ha scritto:
You have received several answers addressing your question while we have
been engaging in a technical discussion about what would make up a good
converter. Whether you like that or not is a different matter, and how to
use search engines is beyond the scope of this newsgroup.
Ok, i have received technical answers but also accusation of lack about
XML2JSON converters... The only practical help was posted by Douglas. I
was wondering just that. Everything else is chats.

Max
Aug 11 '08 #6
Max wrote:
Thomas 'PointedEars' Lahn ha scritto:
>You have received several answers addressing your question while we have
been engaging in a technical discussion about what would make up a good
converter. Whether you like that or not is a different matter, and how to
use search engines is beyond the scope of this newsgroup.

Ok, i have received technical answers but also accusation of lack about
XML2JSON converters... The only practical help was posted by Douglas. I
was wondering just that. Everything else is chats.
Ask for a refund.
Score adjusted

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Aug 11 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1978
by: winderjj | last post by:
Hi All, I need everyones opinion. I am very new to XML but am temporarily putting all my efforts into using it. This is what I need to do. Write an xml parser (in C) that will parse a fairly complicated XML file that is full of technical data(most scalar values). Then I need to store all the info in a C structure. Could some people give me their opinion. Which is better suited for this, Expat or LT xml?
2
3138
by: Martin | last post by:
Hallo, can you help me writing a generic xslt transformation (useable with xsql from oracle)? The problem is how to get the escaping characters .... === INPUT-File in.xml <?xml version = '1.0'?> <person><who>scott</who></person>
8
5750
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
5
3550
by: tobbe | last post by:
Hi Im trying to load a XmlDataDocument with the following xml: <ROOT> <NAME> &LT; &AMP; &GT; " '</NAME> </ROOT> And i know I have a entity problem here, but i cant find any solution for it. The problem is that i recive this from external source and cant
2
4482
by: sp | last post by:
Hello Everybody, I need to convert xml that we get from sqlserver For xml auto to my own xml format using asp.net classes. Any ideas and suggestions would be appreciated. Thanks in Advance sp
10
42974
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me, the XML specification seems a little ambiguous on this, so I defer to the XML authorities. Refer to sections 2.4 and 2.7 (it all hinges on if CDATA attribute values are part of markup or not.) Thanks.
6
1362
by: centizen | last post by:
Preface to the is problem: I am coding in a framework that blends jsp and xml in a heathen manner. Meaning I have to nearly sacrifice a virgin to get anything to work. I want to load the character '<' into a java string. Only problem is that that string is inside a bit of XML. And to compound the problem the string is sent to a browser as part of an html page. The line something looks like: (with a '_' in where the '<' needs be) ...
2
14207
by: Mikus Sleiners | last post by:
I want to create xml document that looks like this: <?xml version="1.0" encoding="utf-16"?> <Draft xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="TravelDraft"> <DraftId>139451de-1bc1-4070-b9d1-548dd4a7f812</DraftId> <StartDate>2006-10-04T00:00:00</StartDate> <RetryCount>0</RetryCount> <LocalCurrencyId>1</LocalCurrencyId> <EndDate>2006-10-25T23:59:59</EndDate>
1
19083
by: Mikus Sleiners | last post by:
I have a task to create xml document from c# code. I have example of that document should look like and also a xml schema. I wonder if i can use this xml schema somehow ? This is schema: <?xml version="1.0"?> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
3886
by: Alpicus | last post by:
Hi, When I execute the following script on SQL Server 2005 SP2 : IF EXISTS (select * from sys.objects where name = 'TEXTEST2' and type_desc = 'USER_TABLE') BEGIN DROP TABLE TEST.TEXTEST2 END CREATE TABLE TEST.TEXTEST2
0
9942
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weĺll explore What is ONU, What Is Router, ONU & Routerĺs main usage, and What is the difference between ONU and Router. Letĺs take a closer look ! Part I. Meaning of...
0
11148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10749
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectŚplanning, coding, testing, and deploymentŚwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7974
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph DuprÚ who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5994
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4618
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3236
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.