本文介绍了json2字符串化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过几篇有关json2.js及其提供的stringify方法的文章.但是,我所看到的帖子来自大约一年前.今天有没有更好的库可以使用,还是jQuery直接支持字符串化功能?

I have seen several posts about json2.js and the stringify method it provides. However, the posts I have seen are from almost a year ago. Is there a better library to use today or does jQuery directly support stringify functionality?

推荐答案

JSON对象已在ECMAScript第5版中定义,并且已在大多数现代浏览器中使用.无需特殊设置.打电话

The JSON object has been defined in ECMAScript 5th ed, and is already available in most modern browsers. No special setup is needed. Calling,

JSON.stringify(someObject)

将吐出传入对象的JSON表示形式.如果您希望与旧版浏览器兼容,则只需在页面上包含Crocford的json2.js. json2.js将使用浏览器的本机实现(如果可用).

will spit out a JSON representation of the passed in object. If you want compatibility for older browsers, then simply include Crocford's json2.js on your page. json2.js will use the browser's native implementation, if available.

这篇关于json2字符串化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 00:01