数组转换为JSON数组、转换为、JSON

2023-09-10 19:09:56 作者:顾念

可能重复:   序列化到JSON在jQuery的   转换对象为JSON字符串

Possible Duplicate: Serializing to JSON in jQuery Convert Object to JSON string

我要转换数组JSON对象JS或jQuery的。      有没有什么功能是可用还是LIB

I want to convert array to json object in js or jquery. Is there any function is available or lib

在此先感谢

推荐答案

在现代浏览器中,你可以简单地使用 JSON.stringify(someJSObject)将任何JavaScript对象(即包括阵列),以一个JSON字符串。

In modern browsers you can simply use JSON.stringify(someJSObject) to convert any JavaScript object (that includes arrays) to a JSON string.

要确保它也可以在更短的现代浏览器,包括https://github.com/douglascrockford/JSON-js/blob/master/json2.js在你的页面。

To ensure it also works in less modern browsers, include https://github.com/douglascrockford/JSON-js/blob/master/json2.js on your page.

 
精彩推荐
图片推荐