Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > XML<-> JSON conversion. What do you think?

Reply
Thread Tools

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

 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-10-2008
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 <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"


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 getElementsByTagName(), 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, <f806at$ail$1$(E-Mail Removed)>
 
Reply With Quote
 
 
 
 
Douglas Crockford
Guest
Posts: n/a
 
      08-10-2008
Max wrote:
> 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. This not only serves to ensure a reversible conversion, but
> especially for documents such as SVG and SMIL that they require a
> precisely correct order of the elements.


That may be true if the text you are dealing with is primarily document. If it
is primarily data, then preservation of document structure will add a lot of
inefficiency to the JSON data structure. A problem in much XML practice is that
it is sometime difficult to understand the difference.

There are a number of transformations possible between JSON and XML. See for
example org.json.XML and org.json.JSONML at www.json.org/java
 
Reply With Quote
 
 
 
 
Max
Guest
Posts: n/a
 
      08-11-2008
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
 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      08-11-2008
Douglas Crockford ha scritto:
> That may be true if the text you are dealing with is primarily document.
> If it is primarily data, then preservation of document structure will
> add a lot of inefficiency to the JSON data structure. A problem in much
> XML practice is that it is sometime difficult to understand the difference.
>
> There are a number of transformations possible between JSON and XML. See
> for example org.json.XML and org.json.JSONML at www.json.org/java


Thank you Douglas. I hope to find a solution to implement a Javascript
converter from XML to JSON.
(Pay attention to page examples on json.org because there are errors)

Max
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-11-2008
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 bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      08-11-2008
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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      08-11-2008
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
 
Reply With Quote
 
Douglas Crockford
Guest
Posts: n/a
 
      08-11-2008
Max wrote:
> (Pay attention to page examples on json.org because there are errors)


That remark is not helpful. If there are errors, it would be helpful if you
specifically identified them. You can thank the community for the free
information you have obtained by providing correct information of your own.
 
Reply With Quote
 
lorlarz
Guest
Posts: n/a
 
      08-11-2008
On Aug 9, 8:19*am, Max <(E-Mail Removed)> wrote:
> 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. This not only serves to ensure a reversible conversion, but
> especially for documents such as SVG and SMIL that they require a
> precisely correct order of the elements.
> For example, in the case of:
>

[snip]
>
> Max


jQuery has a RSS to JSON converter. No doubt order is maintained
here.
You might like to take a look:
http://ejohn.org/projects/rss2json/

 
Reply With Quote
 
lorlarz
Guest
Posts: n/a
 
      08-11-2008
On Aug 11, 10:57*am, lorlarz <(E-Mail Removed)> wrote:
> On Aug 9, 8:19*am, Max <(E-Mail Removed)> wrote:


> [snip]
>
> > Max

>
> jQuery has a RSS to JSON converter. *No doubt order is maintained
> here.
> You might like to take a look:http://ejohn.org/projects/rss2json/


Sorry. That link is to a page for a Perl script to do the conversion
(by John Resig, jQuery creator).

There IS a jQuery "plugin" to do the conversion though (also):
http://plugins.jquery.com/project/xml2json
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lib to generate XML/JSON[P] output from a DTD/XSD/JSON Schema/etc Accio Centeno Python 1 02-15-2013 07:34 AM
I am facing an issue while decoding json string using json.loads sajuptpm Python 2 12-28-2012 07:16 AM
[ANN] Security Fix json-1.1.7 for json_pure and json gems Florian Frank Ruby 0 06-30-2009 05:18 PM
"JSON for ASP" at json.org Turul Topuz ASP General 1 06-27-2008 11:37 PM
ATTN Programmers: WE pay YOU $1.00 if you let us find you a job. jdg Doris Cox Perl 0 12-02-2003 11:07 AM



Advertisments