Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:05:28+00:00 2026-06-04T02:05:28+00:00

I have following Jsonstring var j = { name: John }; alert(j.length); it alerts

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:05:29+00:00Added an answer on June 4, 2026 at 2:05 am

    Lets start with the json string:

    var jsonString = '{"name":"John"}';
    

    you can easily determine its length:

    alert("The string has "+jsonString.length+" characters"); // will alert 15
    

    Then parse it to an object:

    var jsonObject = JSON.parse(jsonString);
    

    A JavaScript Object is not an Array and has no length. If you want to know how many properties it has, you will need to count them:

    var propertyNames = Object.keys(jsonObject);
    alert("There are "+propertyNames.length+" properties in the object"); // will alert 1
    

    If Object.keys, the function to get an Array with the (own) property names from an Object, is not available in your environment (older browsers etc.), you will need to count manually:

    var props = 0;
    for (var key in jsonObject) {
        // if (j.hasOwnProperty(k))
        /* is only needed when your object would inherit other enumerable
           properties from a prototype object */
            props++;
    }
    alert("Iterated over "+props+" properties"); // will alert 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON String. var jsonString = '{J:4,0:M, J:5,0:N}' If I parse
I have a JSON string as the following; { 1: { name: Jerry, age:
I have the following JSON string, which was an Objective C array then encoded
I have the following JS $('#Submit').click(function () { var name = $('#Name').val(); var age
with reference of this question Sort json array I have the following JSON String
I have following json file. { id: 100001740605903, name: Mike Watshan, first_name: Mike, last_name:
I have JSON as follows: [{0:1,id:1,1:abc,name:abc},{0:2,id:2,1:xyz,name:xyz}] It is an array of objects. I need
I have the following code, using Crockford's json2 to parse the object into json
I have following JSON for sending request on server { name:Home, latitude:45.5037078163837, longitude:-122.622699737549, radius:240
I have converted my Datatable to json string use the following method... public string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.