vue json字符串转成数组
时间: 2023-11-08 08:22:12 浏览: 102
通过js实现字符串转数组
可以使用JSON.parse()函数将JSON字符串转换成数组。例如:
var jsonStr = '[{"name":"John","age":30,"city":"New York"},{"name":"Jane","age":25,"city":"Los Angeles"}]';
var arr = JSON.parse(jsonStr);
console.log(arr);
输出结果:
[{"name":"John","age":30,"city":"New York"},{"name":"Jane","age":25,"city":"Los Angeles"}]
阅读全文