Da loro codice:
// Augment the basic prototypes if they have not already been augmented.
// These forms are obsolete. It is recommended that JSON.stringify and
// JSON.parse be used instead.
if (!Object.prototype.toJSONString) {
Object.prototype.toJSONString = function (filter) {
return JSON.stringify(this, filter);
};
Object.prototype.parseJSON = function (filter) {
return JSON.parse(this, filter);
};
}
Credo parseJSON è obsoleto, quindi, la nuova versione (json2) non ha nemmeno usarlo più. Tuttavia, se il codice utilizza parseJSON
molto si può solo aggiungere questo pezzo di codice da qualche parte per farlo funzionare di nuovo:
Object.prototype.parseJSON = function (filter) {
return JSON.parse(this, filter);
};
fonte
2009-02-16 03:30:06
È possibile trovare il nuovo file qui https://github.com/douglascrockford/JSON-js –
Per qualcuno che è venuto a questo chiediti cosa siano questi file, sappi che non c'è motivo di usarli nei browser moderni. Da [GitHub repo] (https://github.com/douglascrockford/JSON-js): "Sui browser correnti, [json2.js] non fa nulla, preferendo l'oggetto JSON integrato. Non c'è motivo di usarlo file a meno che il destino non ti costringa a supportare IE8, che è qualcosa che nessuno dovrebbe mai più fare. " – Thunderforge