I am retrieving some JSON array from PHP in javascript using ajax. First, I parse JSON array and the access each element using a loop. Now I am stuck on a problem there are some numeric objects in JSON array and I can't access them. My JSON array looks like this:
[
{
"Name": "Umar Ghaffar",
"UniqueID": "b57a956420b885ebb",
"loggined": "no",
"Type": "Security",
"0": "0", // how can i get the value of this object
"1": "1"
},
{
"Name": "Usama Ghaffar",
"UniqueID": "af4dc4ac58ee0eb54",
"loggined": "",
"Type": "Security",
"0": "0",
"1": "0"
}
]
This is how I am accessing array
var newText1 = document.createTextNode(data[i].Name);
var newText2 = document.createTextNode(data[i].UniqueID);
var newText3 = document.createTextNode(data[i].loggined);
var newText4 = document.createTextNode(data[i].Type);
var newText5 = document.createTextNode(data[i].0); //here it gives an error
您可以尝试使用括号表示法:
var newText5 = document.createTextNode(data[i]["0"])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.