javascript - 将字符串从 JSON.stringify 转换回数组

标签 javascript html json

是否可以将字符串从 JSON.stringify 转换回数组?

最佳答案

JSON.parse是你的 friend 并回答:)

//examples:
JSON.parse('{}'); // {}
JSON.parse('true'); // true
JSON.parse('"foo"'); // "foo"
JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]
JSON.parse('null'); // null

MDN JSON.Parse details

关于javascript - 将字符串从 JSON.stringify 转换回数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16638006/

相关文章:

html - 无固定断点响应式从水平布局跳转到垂直布局

javascript - 在 React JS 的文本字段中打印 JSON 数据

PHP - json_encode 生成器对象(使用 yield)

javascript - ASP.NET MVC - 如果您不想将 .js 文件存储在/Scripts 中,您会将它们放在哪里?

javascript - 更改 DOM 元素的 insideText 是否会导致新的布局计算/渲染?

javascript - jQuery 变量(在 html 中选择)

json - 尝试使用 Swift 中的 Json token 从服务器获取身份验证

javascript - 使用 Java 脚本编写某个函数

javascript - 使用 Javascript 更改 SVG 的颜色

javascript - 如何将 AngularJS 指令应用于 ajax 内容?