我正在尝试从 JSON 解析字符串并将这些元素转换为 Javascript 中的数组。这是代码。
var data = "{"fname":"Todd","lname":"James","cascade":"tjames","loc":"res","place":"home", "day0":"0,1,2,3,"}";
var getDay = data.day0;
var getDayArray = getDay.split(",");
本质上,我正在尝试获取 day0,即 0、1、2、3,并将其转换为结构为
[0] = 0
[1] = 1
[2] = 2
[3] = 3
这样做的最佳方法是什么?