In javascript, I want to use JSON.stringify
. But some (older) browsers do not recognize JSON
as a defined object. Is there a javascript file that I can include that defines JSON, and all it's awesome functionality, for browsers that do not natively support JSON
?
I should note that I'm referring to a specifically defined JSON
object, rather than t开发者_开发技巧he more general concept of javascript object notation.
Douglas Crockford (the inventor of JSON) provides json2.js, an efficient JSON "parser" that doesn't actually parse JSON; it uses regular expressions to sanitise JSON before passing it to eval, and falls back on native JSON support if the browser has it.
He also provides a more conventional recursive-descent parser and a state-machine-based parser in the same repo.
精彩评论