JavaScript中JSON.stringify()的替代品 [英] Alternatives of JSON.stringify() in JavaScript
问题描述
在JavaScript中,对于没有本机JSON支持的浏览器, JSON.stringify()
有哪些替代方案?谢谢
In JavaScript, what are the alternatives of JSON.stringify()
for browsers that do not have native JSON support? Thanks
推荐答案
你应该使用库 json2.js
。它是某些浏览器本身包含的标准 JSON.stringify(...)
的基础。
You should use the library json2.js
. It is the basis for the standard JSON.stringify(...)
that some browsers include natively.
你可以在这里找到它起源的页面: https://github.com /douglascrockford/JSON-js/blob/master/json2.js
You can find the page it originated from here: https://github.com/douglascrockford/JSON-js/blob/master/json2.js
脚本自动确保它只添加 JSON。 stringify(...)
方法如果它尚不存在,那么在拥有它的浏览器中就没有危险。
The script automatically makes sure it only adds a JSON.stringify(...)
method if it doesn't already exist so there is no danger including it in a browser that has it.
这篇关于JavaScript中JSON.stringify()的替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!