数组转换为JSON [英] Convert Array to Json

查看:117
本文介绍了数组转换为JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  序列化到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.

要确保它也可以在更短的现代浏览器,包括<一href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js">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.

这篇关于数组转换为JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆