Q:

Get first object from array using getJSON (JQuery) and for.each

Right now, I am getting multiple values listed because I'm appending the objects from the for each loop.
$(document).ready(function(){
$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=51.522035&lon=-0.105732",function(result){

  $.each(result.weather, function(i,item){
  $('#testfield').append('<p>' + item.main + '</p>');
  });

});
});

I only want to have the 1st object from the JSON output into testfield div, not all of it.
I tried this but it didn't work
     $.each(result.weather, function(i,item[0]){

FYI: Sometimes, the weather feed provides more than 1 weather.main. Sometimes, only one.

A:

If you want to access the first element, then simply do that instead of looping:
$('#testfield').append('<p>' + result.weather[0].main + '</p>');
//                                           ^^^
//                          access the first element in result.weather

