Live data from Hacker News

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

blog.mongolab.com

91–100 of 133 posts

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

#91
post #73
post #27

Earlier quoted context omitted.

JSON-schema, if you really need it http://tools.ietf.org/html/draft-zyp-json-schema-03

I haven't been able to find any solid, broad implementations of anything that brings schemas to json - either this ietf standard or something else. Only some half-assed and not developed for years implementations for a single programming language. Are there implementation of the spec you link to?

It's not JSON-schema, but Rx is a schema validation tool for JSON/YAML/etc. that works with many languages:

http://rx.codesimply.com/

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

#92

first thing that comes to mind is saving on bandwith.imagine sending same amount data down the line with less bandwidth.

Actually early proponents of XML used to downplay this by claiming that it will be compressed on wire anyways and it's well-suited to higher compression

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

#93
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…

Cross site scripting. Evaling json enables a vector for javascript code injection and execution.

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

#94
post #43
post #37

Earlier quoted context omitted.

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.

ismarc, thank you for the comment! I really appreciate it -- I didn't know anyone else was using Piqi-RPC (other than myself).

I'd like to know more about your use case and the need for JavaScript generation. I'm open to new ideas. Could you please contact me at alavrik@piqi.org Thanks!

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

#95

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.

At least you get a tag. I deal with a web service that returns a ... ...

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

#96
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…

JS is just not enougth lisp in that way. In lisps you have the parser in your langague (read). You cant call eval on a string and thatway avoiding this securety hole.

(You can call eval on a string but it will just return that same string)

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

#97
post #37

Earlier quoted context omitted.

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.

Thanks! Feel free to reuse as many ideas as you like :) It took me more than 2 years to get it there -- it is by far the toughest system I've ever designed.

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

#98

Earlier quoted context omitted.

Yes! I was shocked to see him recommend the use of a straight eval for parsing JSON. json2.js is a must! JSON.parse and JSON.stringify are your friends. https://github.com/douglascrockford/JSON-js/blob/master/json...

just pointing out to others although the parent probably already knew, but JSON.parse is native in all modern browsers, json2 is only needed if you support older browsers (ie7)

Holy crap, I did not know that.

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

#99
post #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 t…

In fairness, I pared down the example for clarity (and to protect the guilty).

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

#100

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.

Afraid not. The WSDL is so baroque, so deeply nested with objects inside objects inside objects, that no SOAP client is capable of parsing it.

To write requests, I've had to resort to building templates manually. To read responses, I've had to resort to walking the DOM tree to hunt-and-peck for the fields I need.

Post reply on HN