Q:

Can not parse JSON with JavaScript parser. Square brackets

I using JavaScript JSON library to parse JSON encoded array, received via POST.
Here is my code:
    var itemsRequest = '[{"id":"142"},{"id":"152"}]';
    var items = JSON.parse(itemsRequest);
    for(var i = 0; i<items.count(); i++)
            {
                var item = items[i];
                alert(item.id);
            }

I am not sure why, but the parser is just not liking that. How can I get it to parse?

A:

Try items.length instead of items.count().

A:

An array doesn't have a count method. Use the length property:
for (var i = 0; i < items.length; i++) {

Demo: http://jsfiddle.net/Guffa/Rt4db/

