Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: JSON or XML? (JSON!)

by tye (Cardinal)
on Apr 24, 2012 at 02:48 UTC ( #966716=note: print w/ replies, xml ) Need Help??


in reply to Re: JSON or XML?
in thread JSON or XML?

I'm not sure what kind of answer you're expecting.

"XML sux! JSON rules!" ?

I have a hard time imagining any data that I'd rather get in XML than in JSON. No, actually, I am completely failing to imagine data that I'd rather get in XML than in JSON.

Have you ever tried to deal with an XML parser? What a recipe for frustration! Have you ever tried to programmatically generate XML? I find that to be an excellent way to find many modules that provide cumbersome (and worse) interfaces for a task.

I guess XML has the potential to let you create a DTD (or even just namespaces). Though, I have yet to have a DTD actually prove useful (and my experience with XML namespaces is "100% pain" so far). I can see the theoretical benefit of such. But, no, I don't see that out-weighing the many other significant pains from dealing with XML. I think the need to invent the complex thing that is a DTD is mostly a demonstration of how painful XML is to work with, creating the need for advanced tools to compensate.

Then there is the complete refusal of XML to allow "data" to include something as mundane as a form-feed character. Sure, you can come up with some additional encoding to embed into the XML... For example, you could encode your binary data into the extremely simple and capable format of JSON and then embed the JSON into the XML.

I also sometimes wish JSON allowed for comments and ordered pairs. But, really, you can just use a list for ordered pairs. And there are even advantages for defining how to include the comments as part of the data (if you don't want to just go slightly outside the JSON standard and allow Java-style comments). (And I sometimes wish JSON didn't allow any types of scalar data other than strings.)

I guess using JSON as a mark-up language for a 98%-text document (like a web page) seems a bit strange. But I suspect, in practice, if you define the structure well, it won't be any worse than trying to edit HTML. But that's a bit of a stretch for something that I'd call "data" anyway.

Pretty much when I say "data", I mean "something that fits in JSON". JSON came along and nicely defined the crux of "what is data?" when talking about sending data between end-points not confined to a single process. It is just too bad that it wasn't formalized much earlier. It would've greatly simplified the HTTP protocol, for example.

- tye        


Comment on Re^2: JSON or XML? (JSON!)
Re^3: JSON or XML? (JSON!)
by Tanktalus (Canon) on Apr 25, 2012 at 19:25 UTC
    No, actually, I am completely failing to imagine data that I'd rather get in XML than in JSON.

    So, when will we be able to get data from perlmonks in JSON instead of XML? :-D

    /me ducks and hides.

Re^3: JSON or XML? (JSON!)
by toro (Beadle) on Apr 25, 2012 at 22:31 UTC

    Thanks!

    DTD
    So this means something like defining your own language? E.g.
     <barber></barber>, <scissors></scissors> 
    instead of
     <paragraph></paragraph>, <bold></bold> 
    etc. ?

    But, really, you can just use a list for ordered pairs.
    You can even pass an entire time series with JSON. http://vimeo.com/35005701

    I sometimes wish JSON didn't allow any types of scalar data other than strings.
    "Numbers are not quoted. It would be insane to require quotes around numbers." —Douglas Crockford http://www.json.org/fatfree.html

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-09-02 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (33 votes), past polls