Javascript 在JS中将字符串类型的对象数组转换为数组类型
我试过:Javascript 在JS中将字符串类型的对象数组转换为数组类型,javascript,node.js,regex,Javascript,Node.js,Regex,我试过: let obj = '[{levelNames:"panasia",order:1,attributes:{name:"string",age:"number"}}]'; const myResult = JSON.parse(obj); 实际: SyntaxError:JSON中位置2处的意外标记l 预期: console.log(myResult); console.log(Array.isArray(myResult)
let obj = '[{levelNames:"panasia",order:1,attributes:{name:"string",age:"number"}}]';
const myResult = JSON.parse(obj);
实际:
SyntaxError:JSON中位置2处的意外标记l
预期:
console.log(myResult);
console.log(Array.isArray(myResult));
非常感谢您提供的任何帮助您的输入基本上是错误的。改为JSON,这样您就可以解析它了。@CertainPerformance您可以提供一个例子。这真的会有帮助
[{levelNames:"panasia",order:1,attributes:{name:"string",age:"number"}}]
true