1

I got this json string

{
    "ResultSet": {
        "version": "1.0",
        "Error": 0,
        "ErrorMessage": "No error",
        "Locale": "us_US",
        "Quality": 40,
        "Found": 2,
        "Results": [{
            "quality": 72,
            "latitude": "19.113130",
            "longitude": "72.873140",
            "woetype": 22
        }, {
            "quality": 72,
            "latitude": "19.094630",
            "longitude": "72.847460",
            "woetype": 22
        }]
    }
}

How do I get the number of groups (not sure of the proper term) under ResultSet.Results using JavaScript?

For instance, in the above example, it is 2, ie. ResultSet.Results[0] & ResultSet.Results[1]

"Results": [{
            "quality": 72,
            "latitude": "19.113130",
            "longitude": "72.873140",
            "woetype": 22
        }, {
            "quality": 72,
            "latitude": "19.094630",
            "longitude": "72.847460",
            "woetype": 22
        }]
1
  • 2
    Correct terminology would be the number of objects in the Results array. Since it's an array, ResultSet.Results.length works perfectly as mentioned below. Commented Dec 17, 2011 at 16:23

1 Answer 1

4
ResultSet.Results.length

This should work, as it is a normal array.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.