我知道这是一个简单的问题......但是我被堆积了。我想将包含字符串的数组数组转换为包含对象的数组数组。JavaScript:将包含字符串的数组数组转换为包含对象的数组数组
what_i_have = [
[
"{"point1":"recommendation number 1 text"}",
"{"point2":"recommendation number 2 text"}"
],
[
"{"point1":1.5}","{"ponit2":2}"
],
[
"{"point1":1.5}","{"point2":2}"
]
]
我想要得到这样的:
what_i_want = [
[
{"point1":"recommendation number 1 text"},
{"point2":"recommendation number 2 text"}
],
[
{"point1":1.5},{"ponit2":2}
],
[
{"point1":1.5},{"point2":2}
]
]
我试了几种方法。数组的JSON.parse()元素的最后一种方式。但是我总是做错了一些事情。 任何建议都会受到欢迎。提前致谢!
嗯,你的第一个代码是无效的。 – epascarello
你可以检查你的单引号和双引号吗? –
是的。道歉。 – Dubliner