Apart from the fact that above thingadongdong† isn't a valid JSON string (test this with jsonlint.com), you'll have to parse your returned string with something like JSON.parse
or json-sans-eval.
After that, you can access your array like any other array, so you can count the number of elements using the length
property.
Assuming your responseText contains a valid JSON string (with all strings encapsulated in double quotes and commas separating key/value pairs), like
[
{
"lastInvAmt": 0,
"bwHrs": 0,
"nbwHrs": 0,
"unbilledAmt": 0,
"unbilledHrs": 0,
"dbID": 0
},
{
"lastInvAmt": 0,
"bwHrs": 0,
"nbwHrs": 0,
"unbilledAmt": 0,
"unbilledHrs": 0,
"dbID": 0
}
]
you can do something like
var myArray = JSON.parse(responseString);
var length = myArray.length;
alert(myArray[0].lastInvAmt); // outputs '0'
† See thingadongdong.com.