外部JSON错误中出现意外令牌

时间:2018-07-28 19:34:20

标签: javascript json

我被要求使用外部json文件更改数据,而对于数据我做了类似的事情

脚本>

    function loadJSON(callback) {

        var xobj = new XMLHttpRequest();
            xobj.overrideMimeType("application/json");
        xobj.open('GET', 'linkto.json', true); // Replace 'my_data' with the path to your file
        xobj.onreadystatechange = function () {
              if (xobj.readyState == 4 && xobj.status == "200") {
                // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
                callback(xobj.responseText);
              }
        };
        xobj.send(null);
     }


function init() {
 loadJSON(function(response) {
  // Parse JSON string into object
    var actual_JSON = JSON.parse(response);
 });
}


     //More Code 

我的Json文件看起来像这样(请注意,这是一个外部JSON文件,不在服务器上,只是一个普通的json文件)

{
    "lae":[
        {
            "lang":"English"
        },
        {
            "lang":"Turkish"
        }
    ],
    "curn":[
        {
            "curr" : "dollar"
        },

        {
            "curr" : "euro"
        }
    ],
    "gnamd":[
        {
            "gname":"poker"
        },
        {
            "gname":"slot"
        }
    ],
    "freeplay": "false"

}

但这在这里引发了意外错误

  "lae" : [

[问题]:知道我可能做错了什么或什么可能导致此错误吗?

0 个答案:

没有答案
相关问题