I am new to JSON
How can I display the following data to the html. for sample I want to display the ‘lat’ and ‘lng’ from the ‘southwest’ or I want to display the ‘text’.
{ “routes” : [
{
“bounds” : {
“northeast” : {
“lat” : -26.758340,
“lng” : 153.035930
},
“southwest” : {
“lat” : -27.454070,
“lng” : 152.852150
}
},
“copyrights” : “Map data ©2011 GBRMPA, Google, Whereis(R),
Sensis Pty Ltd”,
“legs” : [
{
“distance” : {
“text” : “89.7 km”,
“value” : 89693
},
“duration” : {
“text” : “1 hour 17 mins”,
“value” : 4633
},
“end_address” : “Maleny QLD 4552, Australia”,
“end_location” : {
“lat” : -26.758420,
“lng” : 152.852150
},
“start_address” : “Brisbane QLD, Australia”,
“start_location” : {
“lat” : -27.454070,
“lng” : 153.026880
},
}
],
}
] }
Cheers!
As Georgi said, use
$.parseJSON(data).Then, to access the
latandlngproperties, you can use the dot notation:Because
routesis an array object, we use the regular array element accessor ([]) to access the first element (0).