Torno sull'argomento.
Avendo:
codice:
var database = new Object();
database[0] = new Object();
database[0]['codice'] = "COD1";
database[0]['ragioneSociale'] = "RS1";
database[0]['cap'] = "37100";
database[1] = new Object();
database[1]['codice'] = "COD2";
database[1]['ragioneSociale'] = "RS2";
database[1]['cap'] = "37100";
var myJSON = JSON.encode(database);
console.log(myJSON);
Ottengo:
codice:
{"0":{"codice":"COD1","ragioneSociale":"RS1","cap":"37100"},"1":{"codice":"COD2","ragioneSociale":"RS2","cap":"37100"}}
Però vorrei ottenere:
codice:
{identifier:'id',label:'id',items:[ {'codice':'COD1','ragioneSociale':'RS1','cap':'37100'},{'codice':'COD2','ragioneSociale':'RS2','cap':'37100'} ]}
Essendo una struttura dati non posso trattarla come stringa. Come fare??
Grazie!