News for hackers. Stuff that matters.
Re:Why is JSON so popular? Developers want out of the syntax... by zachanker on Wednesday June 22, 2011 @09:52PM (#2686295)
While SimpleXML gives you an easy way to walk the tree, it still requires you to actually do it. All 3 of those examples would require slightly different calls to SimpleXML to handle.
Re:Why is JSON so popular? Developers want out of the syntax... by yahelc on Thursday June 23, 2011 @12:31AM (#2686672)
The moment I realized I could do json_decode(json_encode($simple_xml_object),true); to turn a complex SimpleXML object into an array was the happiest moment of my life.
Re:Why is JSON so popular? Developers want out of the syntax... by mun2mun on Thursday June 23, 2011 @01:37AM (#2686803)
Every day you learn a new thing. Thank you very much.
Re:Why is JSON so popular? Developers want out of the syntax... by 46Bit on Thursday June 23, 2011 @06:57AM (#2687414)
If that works, you're my hero.
Re:Why is JSON so popular? Developers want out of the syntax... by SigmundA on Wednesday June 22, 2011 @10:08PM (#2686335)
what else do you do with a data structure besides walk it at some point? JSON comes out as an acyclic object graph in javascript, so what it still needs to be walked to actually do something with the data.

The difference between walking JSON and XML is simply the syntax of the parser library your are using.

The problem with XML is it has things that don't map directly to most OO languages, like node order matters, and attributes and elements are similar but different things, and mixed content.

So JSON is nice simply because it's close the the OO style everyone is used to today, and is in fact a subset of one of those languages.

IMO either way we need to settle on a way to interchange structured data, and agree on data types, but I would prefer some binary format, text encoding all this data such a waste of space/time.

Re:Why is JSON so popular? Developers want out of the syntax... by zachanker on Wednesday June 22, 2011 @10:32PM (#2686401)
Reiterating the point the blog post makes, but: It's very very easy to structure the same data in different ways in XML. While JSON has the same issue, it's a lot harder to do and you have less flexibility in making bad storage decisions.

You are absolutely right on walking the structure. JSON just tends to be easier (in my experience), even when working with XML libraries that make it less of a pain.

Re:Why is JSON so popular? Developers want out of the syntax... by nowarninglabel on Thursday June 23, 2011 @12:29AM (#2686664)
I'll give the opposing opinion that I find working with XML easier than JSON, but mostly because of QueryPath.
Re:Why is JSON so popular? Developers want out of the syntax... by mythz on Thursday June 23, 2011 @07:10AM (#2687436)
XSLT Parser is that you?