如何在javascript中显示json数组?

时间:2017-10-23 17:07:40

标签: javascript json

print(data.xpath("./text()[last()]")[0].strip())
它只是显示了 [object Object],[object Object],[object Object],[object Object],[object Object]

如何在“帐户”中输入“login”:“admin@bmwcci.org”:

<script>

var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        myObj = JSON.parse(this.responseText);
        document.getElementById("bmwcci").innerHTML = myObj.accounts;
    }
};
xmlhttp.open("GET", "listbmwcci.php", true);
xmlhttp.send();

</script>

1 个答案:

答案 0 :(得分:0)

您可以这样访问,result.accounts[0].login

<强>样本

&#13;
&#13;
var result = {"accounts": [{"uid": 1130000025409057, "iname": "", "sex": null, "ready": "no", "hintq": "", "aliases": [], "enabled": "yes", "maillist": "no", "fname": "", "birth_date": null, "login": "admin@bmwcci.org", "fio": ""}]};

console.log(result.accounts[0].login);
&#13;
&#13;
&#13;