具有如下所示的JSON

callback({
    "response":{
       "docs":[
              {
               "A":"qwe",
               "B":"asd",
               "C":"zxc",
               "D":"mnb",
              }]
       "Mapped Site":[
              "qaw",123,
              "asd",123,
              "qwe",123
              ]
       },
      })


我正在尝试使用Jquery ajax api读取JSON数据,如下所示

$.ajax({
                    type: "GET",
                    url: "http://qqq.com/",
                    crossDomain: true,
                    jsonpCallback: 'callback',
                    contentType: "application/json; charset=utf-8",
                    dataType: "jsonp",
                    success: function (msg) {
                         sourcearr = $(msg.response.Mapped Site);
            sourcearr = $.map(sourcearr, function (el) { return el; });
            alert(sourcearr);
            }
         });


这会在Firebug中引发语法错误,因为Mapped Site中有空格

我该如何转义并读取数据?

最佳答案

您可以访问json键,例如从数组中获取(如果有空格)。

msg.response["Mapped Site"]

10-07 21:41