Live data from Hacker News

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

blog.mongolab.com

41–50 of 133 posts

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

#41
post #3

The problem with XML is that it seemed to encourage more complicated data structures. People sort of forgot that you still have to process all this data. And that, at the end of the day, a lot of it ends up needing to be represented in columns and rows.

No question that's a huge problem; that's the gist of this thread after all.

To my eye the problem with XML is that relational data feels like a hack and people specifying XML default to flattening their data.

My favorite example is a thing called ONIX (for representing bibliographic metadata) which is irredeemably broken, but in world-wide use, none the less.

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

#42
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.

It looks like it was written by someone who wanted to parse their XML using regexps instead of a real parser.

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

#43
post #37

The baby that has been thrown out with the bathwater here is a schema/data description layer. NOT , I repeat NOT , I repeat NOT for verification but rather for tools, so that people working in strongly typed languages can interact with JSON services in a reasonable manner. Unfortunately the one option I see, JSON Schema, appears to have caught the XML/Java bug, and has gotten very complicated.

I couldn't agree more! Out of frustration with existing schema languages and tool support for them, I've been working on Piqi[1] which is concise, expressive and agnostic to data representation formats. It works for JSON, XML and Protocol Buffers. [1] http://piqi.org

I've been using Piqi on a side-project of mine and I must say, I'm horribly impressed (using piqi_rpc with erlang for a web service and javascript based client to retrieve/interact with the data). The only way it could be nicer is if there was the same sort of generator for javascript so I didn't end up having to check/enforce the format at all.

Didn't realize you hung out on HN, so many thanks and great job.

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

#44
post #37

The baby that has been thrown out with the bathwater here is a schema/data description layer. NOT , I repeat NOT , I repeat NOT for verification but rather for tools, so that people working in strongly typed languages can interact with JSON services in a reasonable manner. Unfortunately the one option I see, JSON Schema, appears to have caught the XML/Java bug, and has gotten very complicated.

I couldn't agree more! Out of frustration with existing schema languages and tool support for them, I've been working on Piqi[1] which is concise, expressive and agnostic to data representation formats. It works for JSON, XML and Protocol Buffers. [1] http://piqi.org

That looks very cool. I'll look at it, and maybe steal a few ideas :). I've been working on a data language myself in my spare time, mostly concentrating on generative structures like conditionals and loops and a syntax-independent data model. But Piqi looks to be a lot more ambitious, not to mention mature.

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

#45
post #40
post #4

The post actually appears to endorse using eval to parse JSON. Not only does that allow invalid JSON through, it disallows some valid JSON, and of course is a huge security hole. If you want to handle JSON data in JavaScript use JSON.parse -- it's the safest, fastest, and most correct path to having your data available to you. [update: edited to remove bizarre use of whole vs hole... boggles ]

I gotta ask: that just sounds wrong to me. The fact that it used a built-in parser was supposed to have been a feature of JSON. Have we pedantricized that into a bad thing now too? What's the disadvantage of "allowing invalid JSON" in an application protocol you control? Likewise, what's the value of valid JSON (I honestly don't know what the example here is) that can't be parsed by a Javascript interpreter? And wher…

"And where does the "huge security hole" come from"

eval'ing a response from a third party essentially runs their code in your context. JSON.parse does not.

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

#46
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.

The apache module that provides the gateway to Ecometry? That thing was a bear. I can't believe they did all the processing in the apache module rather than with a CGI.

It didn't actually use regular expressions, but parsed the input with a lot of char pointer manipulation.

The reason it worked like this was to have the "XML" tags map directly to the terminal input screens run on the backend, because it essentially input data as if a human was typing it into the terminal and navigating the forms.

I keep meaning to write this up as the worst example of XML abuse I've ever seen; I'm actually surprised someone else here has used the same thing (or even more surprised that more than one party has implemented the same braindead thing).

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

#47
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.

Every day you learn a new thing. Thank you very much.

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

#48

The baby that has been thrown out with the bathwater here is a schema/data description layer. NOT , I repeat NOT , I repeat NOT for verification but rather for tools, so that people working in strongly typed languages can interact with JSON services in a reasonable manner. Unfortunately the one option I see, JSON Schema, appears to have caught the XML/Java bug, and has gotten very complicated.

Use protocol buffers! As easy to use as JSON in dynamic languages, gives you strongly-typed accessors in static languages.

Yeah... no. I'm not a big code gen guy.

But the google people seem to love them, so I'm probably in the minority.

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

#49

The baby that has been thrown out with the bathwater here is a schema/data description layer. NOT , I repeat NOT , I repeat NOT for verification but rather for tools, so that people working in strongly typed languages can interact with JSON services in a reasonable manner. Unfortunately the one option I see, JSON Schema, appears to have caught the XML/Java bug, and has gotten very complicated.

That because schemas are complicated, no matter which way you encode the data. JSON is so nice and easy and simple until it needs all those things that made it into XML to get the job done. I whole heartedly agree, there is nothing sweeter than giving another vendor our WSDL with schema when they ask how to work with our system. It eliminates huge effort and ambiguity in system interaction.

Well, I think there is a middle ground: non-recursive structs, lists, maps, and some judicious "primitives" and basically allowing only natural tree mappings would go a long way, IMO.

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

#50

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.

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