我正在查询LinkedIn JS API以返回人员列表。此列表作为JSON对象返回。这是回调函数:
.result(function (result) {
profile = result.values[0];
// Do something with the first linkedin profile in the list...
});
对象'result'返回如下内容:
{"values":[{"id":"123456","firstName":"Person","lastName":"One"}, {"id":"123456","firstName":"Person","lastName":"Two"}, {"id":"123456","firstName":"Person","lastName":"Three"}],"_total":3}
我见过的所有文档都使用这种语法从结果中获取第n个项目:
var profile = result.values[n];
这在大多数浏览器中运行良好,但在IE中它会引发以下错误:
Microsoft JScript runtime error: Object doesn't support this property or method
有人有任何想法解决这个问题吗?
提前致谢。
答案 0 :(得分:0)
由于'values'键是一个字符串,以下可能有用(抱歉,没有IE测试):
var profile = result['values'][n];