Use a JSON array with objects with javascript

Posted by Fredrik Johansson on Stack Overflow See other posts from Stack Overflow or by Fredrik Johansson
Published on 2010-05-09T21:36:08Z Indexed on 2010/05/09 21:38 UTC
Read the original article Hit count: 444

Filed under:
|

Hi,

I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this:

Variable that I will pass to the function will look like this:

[{"id":28,"Title":"Sweden"}, {"id":56,"Title":"USA"}, {"id":89,"Title":"England"}]

function test(myJSON)
{
    // maybe parse my the JSON variable?
    // and then I want to loop through it and access my IDs and my titles
}

Any suggestions how I can solve it?

Regards, Fredrik

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript