【发布时间】:2012-02-08 17:45:22
【问题描述】:
可能重复:
Serializing to JSON in jQuery
Convert Object to JSON string
我想在 js 或 jquery 中将数组转换为 json 对象。 有没有可用的函数或lib
提前致谢
【问题讨论】:
标签: javascript jquery html ajax json
可能重复:
Serializing to JSON in jQuery
Convert Object to JSON string
我想在 js 或 jquery 中将数组转换为 json 对象。 有没有可用的函数或lib
提前致谢
【问题讨论】:
标签: javascript jquery html ajax json
在现代浏览器中,您可以简单地使用 JSON.stringify(someJSObject) 将任何 JavaScript 对象(包括数组)转换为 JSON 字符串。
为确保它也适用于不太现代的浏览器,请在您的页面上包含 https://github.com/douglascrockford/JSON-js/blob/master/json2.js。
【讨论】:
怎么样
var jsonString = JSON.stringify(myArray);
【讨论】: