我正在使用为我提供此变量的 firefox 插件:
[{errorMessage:"TypeError: a is null", sourceName:"http://pagead2.googlesyndication.com/pagead/js/graphics.js",
lineNumber:17, console:null}]
从 firebug 中,我可以看到这个变量及其名称“e”。
我可以输入 e,然后按上面的方式打印它。
如果我输入 e.toString();我明白了,
[对象对象]
如果我输入 e.errorMessage,它是未定义的。
如果我输入 JSON.parse(e),我会收到意外的字符错误。
如何从这个对象中获取信息?似乎我对它做的任何事情,它都只会返回 [object Object] 或 undefined。
我已经尝试过 JSON.parse、JSON.stringify,遍历它,但没有任何东西能为我提供实际的对象信息。
最佳答案
这是一个包含对象的数组,试试这个:
e[0].errorMessage;
关于javascript - 无法解析 JSON 对象、Stringify 或获取 javascript 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19236679/