I'm using JSON.stringify and JSON.parse to edit my JSON file based on changes to an online database. Everything works right, except it is making quotes around a number which is screwing up the JSON file. For example it should be "id": 1
but it is printing out "id": "1"
. How would I edit the quotes out? I prefer to use JSON.stringify and not an alternative.
Here is where I'm stringifying it and using BackboneJS:
var Territories = Backbone.Collection.extend({
model: Territory,
url: "examples/olympics.json",
initialize: function () {
Backbone.Model.prototype.initialize.apply(this, arguments);
this.on("change", function (model, options) {
var data1 = JSON.stringify(this);
obj = JSON.parse(data1);
$.ajax({url:"testingphp.php",type:"POST",data:{
"data3":obj
}
});
if (options && options.save === false) return;
});
}
});