All current browsers support window.JSON.parse(). It takes a formatted JSON string and returns an object or Javascript array.
Demo: http://jsfiddle.net/ThinkingStiff/KnbAJ/
Script:
var json = '{"some_id":[{"city":"Bellevue"},{"state":"Washington"}]}'
object = window.JSON.parse( json );
document.getElementById( 'length' ).textContent = object.some_id.length;
document.getElementById( 'city' ).textContent = object.some_id[0].city;
document.getElementById( 'state' ).textContent = object.some_id[1].state;
HTML:
length: <span id="length"></span><br />
some_id[0].city: <span id="city"></span><br />
some_id[1].state: <span id="state"></span><br />
Conclusion:
length: 2
some_id[0].city: Bellevue
some_id[1].state: Washington
source
share