9 ms·
eval() isn't quite the same. It's unsafe for starters: it permits any JS code, not just JSON. But JavaScript has the JSON object offering a high-quality, high-
by TazeTSchnitzel 11y ago
eval() isn't quite the same. It's unsafe for starters: it permits any JS code, not just JSON.
But JavaScript has the JSON object offering a high-quality, high-performance parser (JSON.parse) and serialiser (JSON.stringify).
- ape4 11y agoIts funny how JSON emerged as subset of JavaScript - easy to parse with eval(). But now if you do that its terrible code. So the subset aspect is totally irrelevant now.
- heydenberk 11y agoThe subset aspect is indeed still relevant. JSONP callbacks[0] make use of JSON's just-JavaScript nature. [0] https://en.wikipedia.org/wiki/JSONP https://en.wikipedia.org/wiki/JSONP
- TazeTSchnitzel 11y agoIn old browsers, yes. The much more secure CORS is now an option, however.