我试图将字符串解析为JSON对象,但它不起作用。我调试代码时出现语法错误。这里是我想解析的字符串:将字符串类型解析为JSON对象时出错
var listString = "{ title: 'MySchema'," + "root: {id:'" + headID + "',"
+ "title:'" + topHead[0].Designation + "'," + "subtitle:'" + headName + "',";
liststring = liststring + "{ id: '" + head + "'," + "title: '" + childs[cnt].Designation + "'," + "subtitle: '" + title + "'," + "type: '" + childs[cnt].Typav + "'";
liststring = getChildNodes(tasksEntries, head, liststring); liststring = liststring + "},";}liststring = liststring + "]}}";} listString = childliststring;
$ .parseJSON(listString);
我没有得到任何JSON对象的回报。有什么想法吗?
是,该字符串不是有效的JSON对象,所以它使你无法解析它作为一个道理。 –