Problem with multidimensional response

Problem with multidimensional response

/* I have an json query that returns: */

/*

?(
[
  • {
    • label"Thomas",
    • value"Thomas",
    • id"34"
    },
  • {
    • label"Tiesto",
    • value"Tiesto",
    • id"12"
    }
]
)
*/
/*

I'm trying to get the response's "id" field value, but jquery always returns the label field value or an empty value. How do I to get this third? I want to get it and add it to a <span> who will have "id" field with the response's "id" value inside.
*/

$(function(){
//attach autocomplete
$("#adicionaEventoAtracaoWarmup").autocomplete({
//define callback to format results
source: function(req, add){
//pass request to server
$.getJSON("evento/processa.php?acao=buscarAtracao&callback=?", req, function(data) {
//create array for response objects
var suggestions = [];
//process response
$.each(data, function(i, val){
suggestions.push(val.label);
});
//pass array to callback
add(suggestions);
});
},

//define select handler
select: function(e, ui) {
//create formatted friend

var atracao = ui.item,





// HERE IS THE PROBLEM... TRYING TO ADD THE ID ATTR I'M ALWAYS GETTING THE LABEL OU AN EMPTY VALUE


span = $("<span>").text(atracao.label).attr({id: atracao.id}),
a = $("<a>").addClass("remove").attr({
href: "javascript:",
title: "Remover " + atracao,
}).text("x").appendTo(span);
//add atracao to atracao div
span.insertBefore("#adicionaEventoAtracaoWarmup");
$("#adicionaEventoAtracaoWarmup").text(""); 
}, 
//define select handler
change: function() {
//prevent 'to' field being updated and correct position
$("#adicionaEventoAtracaoWarmup").val("").css("top", 2);
}
});
});