【发布时间】:2016-06-09 20:19:19
【问题描述】:
我从服务器接收到一个 JSON 对象,并循环访问该对象以收集某些信息。我首先需要检查特定位置的对象中是否存在某个键。我这样做如下:
if (dataJSONobj.responseText['ops:world-patent-data']['ops:equivalents-inquiry']['ops:inquiry-result'][i]['exchange-documents']['exchange-document']['bibliographic-data']['references-cited']['citation'][j]['nplcit'])
//the key is in there
但是,我每次都会收到此错误:
CaseSelector.js:322 Uncaught TypeError: Cannot read property 'nplcit' of undefined*** when there is not a "nplcit" key.
我的语法有什么问题?我什至通过询问该密钥是否不等于 null 来尝试相反的操作。
【问题讨论】:
-
你能发布json对象吗?
-
@bhspencer - [j] 很不稳定。韦斯顿在下面正确回答。
标签: javascript json web-services api