Javascript 访问JSON中的密钥
我将一个HashMap从Java端传输到Javascript端,我可以在Java端调试我的映射,也可以在浏览器控制台上查看 如果我写:Javascript 访问JSON中的密钥,javascript,json,Javascript,Json,我将一个HashMap从Java端传输到Javascript端,我可以在Java端调试我的映射,也可以在浏览器控制台上查看 如果我写:console.log(responseFromServer[0].userAttributes) 但是当我试着写作的时候 console.log(responseFromServer[0].userAttributes['uid']); 或 我看到null 我错在哪里?我正在使用DWR,我错过了Java控制台上关于缺少转换器的错误 我将bean添加到dwr.x
console.log(responseFromServer[0].userAttributes)代码>
但是当我试着写作的时候
console.log(responseFromServer[0].userAttributes['uid']);
或
我看到null
我错在哪里?我正在使用DWR,我错过了Java控制台上关于缺少转换器的错误
我将bean添加到dwr.xml:
<dwr:convert type="bean" class="com.entity.OrganizationAttributeValue"/>
可能存储在userAttributes.uid中的数组包含字符串或值null
?因为我们不知道这些数据,所以我们无能为力。这与JSON无关。顺便说一句,您有一个普通的JavaScript对象。在这里发布一个responseFromServer
的示例。还包括如何在JavaScript中请求数据。
console.log(responseFromServer[0].userAttributes.uid);
<dwr:convert type="bean" class="com.entity.OrganizationAttributeValue"/>