In one of the jsp pages from my project, I have to work with this json lists:
var obj_tipo = jQuery.parseJSON( "{"Tipo":[{"id":3,"nome":"gerente"},{"id":4,"nome":"supervisor"},{"id":5,"nome":"analista"},{"id":6,"nome":"tecnico"},{"id":7,"nome":"secretaria"},{"id":8,"nome":"seguranca"}]}" );
var obj_campo = jQuery.parseJSON( "{"Key":[{"id":1,"nome":"e-mail"},{"id":2,"nome":"cidade"}]}" );
I try read each item of the list this way:
for(var item in obj_tipo.Tipo)
select.append('<option value="'+item.nome+'">'+item.nome+'</option>');
and
for(var item in obj_campo.Key)
$("table.cadastro").append('<tr> <td> '+item.nome+' : </td> <td> <input type="text" name="'+item.nome+'" size=20 maxlenght=40> </td> <tr>');
But I am getting the text 'undefined' when I display the page, instead of the corret text, despite the fact that the right amount of itens are being displayed.
Someone knows how to fix that? What the right way to access each item from my json list? the list is well formed, right?