Live data from Hacker News

Why is JSON so popular? Developers want out of the syntax business

blog.mongolab.com

81–90 of 133 posts

Re: Why is JSON so popular? Developers want out of the syntax business

#81
post #39

Earlier quoted context omitted.

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.

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.

If that works, you're my hero.

Re: Why is JSON so popular? Developers want out of the syntax business

#83

Earlier quoted context omitted.

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.

I'll give the opposing opinion that I find working with XML easier than JSON, but mostly because of QueryPath.

XSLT Parser is that you?

Re: Why is JSON so popular? Developers want out of the syntax business

#84
post #50

Earlier quoted context omitted.

Apparently one doesn't need to be awake, sane or sober to become an enterprise "programmer".

Apparently one doesn't need to be awake, sane or sober to become a "programmer". Fixed. I've seen plenty of crap programming everywhere, no need to pick on enterprise programmers.

Except that bad programmers in other domains will typically shrug and say "so what" when you point out the lack of code quality while enterprise programmers will try to convince you that their twisted ways are actually better. IME, ofcourse.

Re: Why is JSON so popular? Developers want out of the syntax business

#85

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

If that is the worst XML that you have experienced then you have been very very lucky. I've seen stuff that:

- Has been built by string manipulation and therefore isn't well formed and needs hacky preprocessing before being parsed (no not HTML)

- Is full of redundant information (e.g. count attributes giving the number of child elements)

- Makes evil use of vast numbers of namespaces where the element names are all the same

- Is a basically a container for delimited or fixed format data

- Had attributes that contained entire encoded XML documents

There are probably some other horrors that therapy and/or alchohol have let me forget (like systems doing SQL queries doing string compares on lumps of XML).

I really like JSON these days...

Re: Why is JSON so popular? Developers want out of the syntax business

#86
post #33

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

I've worked with worse: John Smith 123 Some Street Blah Blah Blah ... and so on. I can't think of any advantage to (or excuse for) doing it this way. The only possible reason for it that I can think of, is rather comprehensive ignorance of how XML and related standards work.

I can top this; I once worked with an api that returned XML with 1 node that contained a string of more XML.

Re: Why is JSON so popular? Developers want out of the syntax business

#87

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

Are you really having to deal with the SOAP protocol yourself? I mean, their are libraries that handle all this for you. Just read in the WSDL, and call the methods as you need them. No need to muck around with XML.

Of course there are libraries that do all of this stuff - and they work nearly all the time. However, when they stop working you end up having to look at what is actually going over the wire (or WDSL if you are really unlucky) to try and work out what on earth is going on.

98% of the time SOAP works without too many problems - the trouble is that those other 2% of cases can be truly awful to debug because you have then got to wade through all of the crap that is in there to support the "easy to use" functionality.

SOAP should die.

Re: Why is JSON so popular? Developers want out of the syntax business

#88
post #36

Map m = new HashMap(); m.put("a", 1); m.put("b", 2); m.put("c", 3); . . . The single worst thing in Java?

I think the current way to write that is to either use Google Guave ImmutableMap.of("a", 1, "b", 2, "c", 3) or when mutable maps are required, to write: Map m = new HashMap() {{ put("a", 1); put("b", 2); put("c", 3); }};

Both of these are a bit lighter yet still far away from JavaScript or Ruby special syntaxes.

Re: Why is JSON so popular? Developers want out of the syntax business

#90

The best way I've encountered to construct XML: first-name John last-name Smith I kid you not. That's what I'm dealing with at work right now. Thank you, enterprise SOAP solutions.

I'm a little embarrassed to admit this, but when I first read your post, I honestly thought that you were giving an example of how simple XML can be! After all, I can quickly glance at this bit of XML and understand what it is intended to represent. This doesn't look like SOAP-style xml to me at all, it looks like simple XML over HTTP.

It gets so much worse that this. Much of the generated XML I've seen (especially the stuff used for SOAP) is nearly unreadable by humans.

Post reply on HN