将多维 javascript 数组转换为 JSON? [英] Convert a multidimensional javascript array to JSON?

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

问题描述

将多维 javascript 数组转换为 JSON 的最佳方法是什么?

What is the best way of converting a multi-dimensional javascript array to JSON?

推荐答案

大多数流行的 JavaScript 框架都包含 JSON 实用程序函数.例如,jQuery 有一个函数可以直接调用 url 并将 JSON 结果作为对象加载:http://docs.jquery.com/Getjson

Most of the popular JavaScript frameworks have JSON utility functions included. For instance, jQuery has a function that directly calls a url and loads the JSON result as an object : http://docs.jquery.com/Getjson

但是,您可以从 json 网站 获得开源 JSON 解析器和字符串化器:

However, you can get an open-source JSON parser and stringifier from the json website :

https://github.com/douglascrockford/JSON-js

然后,只需包含代码并在数组上使用 JSON.stringify() 方法.

Then, simply include the code and use the JSON.stringify() method on your array.

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

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