Open GoogleCodeExporter opened 8 years ago
FWIW http://kangax.github.com/es5-compat-table/ says that all modern browsers
now support ES5's JSON object.
Original comment by jeffschi...@google.com
on 17 Sep 2010 at 8:43
It would be nice but it turns out that this is not straightforward to do. The
main reason is that eval is much more lenient than the built-in JSON parser and
would break a ton of users.
Original comment by chrishe...@google.com
on 23 Apr 2012 at 9:06
Another reason this would be nice to have, aside from the performance gains, is
that it would allow Closure's JSON functions to be used with a Content Security
Policy that disallows eval.
re #2, would it be reasonable to control this with a compile-time flag?
/**
* Use the native JSON.parse and JSON.stringify, for goog.json.*, if available.
* @define {boolean}
*/
goog.USE_NATIVE_JSON = false;
Then users who do nothing will continue to get eval(), and those who want the
native behavior can set the flag at compile time.
Or, there could be two separate functions, parse and nativeParse. Thoughts?
Original comment by tbreisac...@google.com
on 9 Aug 2012 at 10:52
The Chrome Extension Security Policy now disallows inline JavaScript as well as
"dangerous string-to-JavaScript methods like eval".
https://developer.chrome.com/extensions/contentSecurityPolicy.html
It would be great if this issue could be prioritized to avoid forcing all
extensions using goog.json.parse() to switch over to JSON.parse().
Original comment by matti...@google.com
on 15 Aug 2012 at 10:30
Sounds like the recommendation for code that needs to use eval is to override
goog.json.parse.
goog.json.parse=JSON.parse
Original comment by le...@google.com
on 17 Aug 2012 at 4:44
Original issue reported on code.google.com by
bolinf...@gmail.com
on 8 Dec 2009 at 4:36