4 ms·
> The point of JSON is to have a lighter and simpler way of data interchange, where the data is arrays and maps of strings and numbers. It also works well with
by otterley 12y ago
> The point of JSON is to have a lighter and simpler way of data interchange, where the data is arrays and maps of strings and numbers. It also works well with Javascript.
I contend there's no "point" to JSON at all. JSON is simply JavaScript (in fact, you can eval it) that was discovered could be used to send data from servers to browsers. It became a standard out of sheer convenience.
By breaking Javascript's ability to execute the code, you're eliminating an important feature of JSON. (I'll admit that nobody should be eval'ing JSON, but the fact that you can makes its existence better understood.)
- gnaritas 12y agoNo you can't, JSON is not JavaScript and eval is not capable of working on all correct JSON documents. JSON requires a JSON specific parser. So this breaks nothing, eval doesn't work now and JSON has never been JavaScript.
- otterley 12y agoWhen JSON was first used, it was evaluated with eval. Certain issues might cause JSON not to evaluate properly (the only article I could find arguing that it's not Javascript involve Unicode issues that are rarely encountered), but it doesn't invalidate my point.
- draegtun 12y agoAnd to back up gnaritas comment... JSON: The JavaScript subset that isn't - http://timelessrepo.com/json-isnt-a-javascript-subset http://timelessrepo.com/json-isnt-a-javascript-subset
- deleted 12y ago[deleted]
- ninjaplease 12y agoLook, you're just wrong. The only exception to "eval" is some obscure unicode bug others are mentioning. JSON is literally a JS object literal (with the additional requirement that any key be a string). There's also no reason to use eval when JSON.parse will do it safely.
- gnaritas 12y agoNo I'm not wrong and there mere fact that you mention the exception means you've conceded my point; and those aren't bugs, they're in the spec which means it was never a subset of JS. > JSON is literally a JS object literal (with the additional requirement that any key be a string). Which makes it not a JS object literal but a near subset with slightly different rules with unicode strings that make it not even a subset.
- ninjaplease 12y agoWhat spec are you looking at? http://www.ietf.org/rfc/rfc4627.txt http://www.ietf.org/rfc/rfc4627.txt specifically says in section 2.5 that all unicode characters are meant to be supported. So now you're wrong twice.
- gnaritas 12y agoTry learning something jackass: http://timelessrepo.com/json-isnt-a-javascript-subset http://timelessrepo.com/json-isnt-a-javascript-subset