Displaying

by E D

JavaScript

var data='{"indicator_value": {"HDI":{"AFG":{"2009":"0.404","2010":"0.426","2011":"0.428"}}},"country_name": {"AFG": "Afghanistan"}, "indicator_name": {"HDI": "Human Development index"}}'

// parse the data and store the result in var json
var json= JSON.parse(data)
//show the result for HDI, AFG, in 2010
document.write('<br>Indicator is <b> '+json["indicator_name"]["HDI"]+'</b><br>')
document.write('Country:<b> '+json["country_name"]["AFG"]+'</b><br>')
document.write('Value for 2010 = <b>'+json["indicator_value"]["HDI"]["AFG"]["2010"]+'</b>');