The code below is from wunderground weather api, and I'm using javascript to print json data, but how can I print a specific row from json?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/<apikey>/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
For example in ['location']
, to get the first result because it can be array ['location'][0]
something like this
location
is a single object. – Sheikh Heera Nov 5 '12 at 17:12For example in ['location'] to get the first result because it can be array ['location'][0]
If it is an array, then access it with array notation. – Chad Nov 5 '12 at 17:21