我在 JavaScript 中遇到读/写错误,因为我的 JSON 文件默认为只读(“未捕获的 TypeError:无法分配给只读属性”)。如何将其指定为可写?在 JavaScript 或 JSON 中?
我的 JSON 数组是这样的(“可写:真”应该去这里吗?):
{ "lots" : [
{
"name" : "NW Corner of HW30 & 54th",
"info" : "$2/Hr<br>Monthly Parking Available",
"center" : {
"lat" : 57.659390,
"lng" : -127.414754
},
"topLeft" : {
"lat" : 57.659616,
"lng" : -127.415102
},
"bottomRight" : {
"lat" :57.659208,
"lng" :-127.414371
}
}...etc
]}
这是我的 Ajax 调用(我可以在此处使用 Object.defineProperty() 指定可写吗?):
var jsonFile = $.ajax({
type: "GET",
url: "filepath/filename.json",
dataType: "json",
success: function(response) {
console.log(response);
}
});
还是我需要完全在其他地方声明它?
非常感谢您的帮助。