I hava JSON oggetto:eccezione JavaScript: Uncaught TypeError: Conversione struttura circolare a JSON
[#1={id:"2012-05-04", title:"Scheduled", start:(new Date(1336096800000)), source:{events:[#1#], className:[]}, _id:"2012-05-04", _start:(new Date(1336089600000)), end:null, _end:null, allDay:true, className:[]}]
provo a stringa i esso:
var test = JSON.stringify(resourceVacation, censor(resourceVacation));
function censor(censor) {
return (function() {
var i = 0;
return function(key, value) {
if (i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
++i; // so we know we aren't using the original object anymore
return value;
}
})(censor);
}
Io uso censore come indicato qui: Chrome sendrequest error: TypeError: Converting circular structure to JSON n
Tuttavia ottengo la seguente eccezione sul browser:
Uncaught TypeError: Converting circular structure to JSON
Ecco l'oggetto Java Script:
ho avuto l'oggetto precedente JSON utilizzando toSource() al browser Mozilla. Qualche idea su come sistemarlo !!
UPDATE ============================ ================= =======
in realtà ho bisogno di condividere con voi la scnerio dall'inizio: 1 -primo: ho una forma e alla fine ho costruire java oggetto script che è:
#1=[{id:"2012-05-03", title:"Scheduled", start:(new Date(1336010400000)), source:{events:#1#, className:[]}, _id:"2012-05-03", _start:(new Date(1336003200000)), end:null, _end:null, allDay:true, className:[]}]
Questo oggetto è stringata normalmente ... si noti che "S tipico a quello che avrebbe sparato in seguito eccezione.
2- Poi la ter a cancellare gli oggetti di questo array utilizzando:
function deleteVacation(day) {
for (var index = 0; index < resourceVacation.length; index++) {
if (resourceVacation[index].id == day)
resourceVacation.splice(index,1);
}
3-Quando cerco di stringa i cui matrice dopo ho cancellato un singolo oggetto, ottengo l'eccezione menzionato. Quindi .. anu idee perchè è passato la prima volta e fallito 2a volta !!
Convalida il JSON. Sembra non essere valido: http://www.jsonlint.org –
In realtà quello che ho già è array di oggetti e ho usato obj.toSource() per ottenere quel json. – Echo
Ho aggiornato il mio post.Please feed me back se avete qualche preoccupazione. – Echo