I have following Jsonstring
var j = { "name": "John" };
alert(j.length);
it alerts : undefined, How can i find the length of json Array object??
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Lets start with the json string:
you can easily determine its length:
Then parse it to an object:
A JavaScript
Objectis not anArrayand has no length. If you want to know how many properties it has, you will need to count them:If
Object.keys, the function to get anArraywith the (own) property names from anObject, is not available in your environment (older browsers etc.), you will need to count manually: