problem parsing JSON Strings

Posted by blacktooth on Stack Overflow See other posts from Stack Overflow or by blacktooth
Published on 2010-05-07T16:33:01Z Indexed on 2010/05/07 16:38 UTC
Read the original article Hit count: 283

Filed under:
|
|
var records = JSON.parse(JsonString);

for(var x=0;x<records.result.length;x++)
{
  var record = records.result[x];
  ht_text+="<b><p>"+(x+1)+" "
    +record.EMPID+" "
    +record.LOCNAME+" "
    +record.DEPTNAME+"  "
    +record.CUSTNAME
    +"<br/><br/><div class='slide'>"
    +record.REPORT
    +"</div></p></b><br/>";
}

The above code works fine when the JsonString contains an array of entities but fails for single entity. result is not identified as an array! Whats wrong with it?

http://pastebin.com/hgyWw5hd

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript