Q:

jquery format json and display as a ul >li

I am getting the following json string after the data has been posted via an ajax request.  
{
 "first_name":["The first name field is required."], 
 "last_name":["The last name field is required."], 
 "email":["The email field is required."], 
 "usercode":["The usercode field is required."], 
 "password":["The password field is required."], 
 "password_confirmation":["The password confirmation field is required."], 
 "captcha":["The captcha field is required."] 
}

what i would like to do is to parse the above string and display them as li elements.  
I am doing something like the following
for(var i=0;i<=json.length;i++)
{
     $('#errorArea > ul').append("<li>" + json[i] + "</li>")
}

but I am not getting the expected result.  
Can you please let  me know what I am doing wrong?  

A:

Your JSON is being parsed to an object, and objects in JavaScript don't have a length property, only arrays and array-like objects do. 
Instead, iterate over the object with
for (var i in json)

Your other line, inside the loop, would remain unchanged.