Javascript - Iterate key-less JSON

accidentgirly

New Member
I have string array converted to JSON. It looks like\[code\]var data = http://stackoverflow.com/questions/7246465/["[None]","data","data2"]\[/code\]So, there's no key/value pair. This causes my JSON iteration to bomb:\[code\] for (var i = 0; i < data.length; i++) { var obj = data; alert(obj); for (var key in obj) { var attrName = key; var attrValue = http://stackoverflow.com/questions/7246465/obj[key]; alert('key: ' + attrName + 'value: ' + attrValue); } }\[/code\]Should I figure out a way to key each object (javascriptserializer created this JSON from a string array)? Or..what do you suggest?After learning a few things from you all, I am still unable to to iterate the data object.\[code\]for (var i = 0; i < data.length; i++) { var obj = data; alert(typeof obj); if (typeof obj === 'object') { alert(obj); for (var key in obj) { var attrName = key; var attrValue = http://stackoverflow.com/questions/7246465/obj[key]; alert('key: ' + attrName + 'value: ' + attrValue); } } else { alert(data); } }\[/code\]I hit the \[code\]else\[/code\], but It goes through the array 1 character at a time. This is not what I want...
 
Top