【发布时间】:2019-11-08 05:45:18
【问题描述】:
$.ajax({
url: "/url/url.ajax?length=100000&startDate=2018-07-01",
method: "get",
dataType: "json",
success: function (jdata) {
var jsonData=JSON.parse(jdata.data);
}
});
响应 Json:
{startIndex: 0, draw: 0, recordsTotal: 22, recordsFiltered: 22, pageNumber: 0,…}
data: [{,…}, {,…}, {,…}, {,…},…]
0: {,…}
1: {,…}
2: {,…}
3: {,…}
4: {shequData: {specialFlag: null, userCode: "17110000003", passportNo: "T02221", id: null,…},…}
5: {,…}
6: {,…}
7: {,…}
8: {,…}
9: {,…}
10: {,…}
11: {,…}
12: {,…}
13: {,…}
14: {shequData: {specialFlag: null, userCode: "ZY88888", passportNo: "Z01917", id: null,…}, remark: null,…}
15: {,…}
16: {,…}
17: {,…}
18: {,…}
19: {,…}
20: {,…}
21: {,…}
draw: 0
pageNumber: 0
recordsFiltered: 22
recordsTotal: 22
startIndex: 0
json 有超过 100000 个字符,所以我发布了 json 的预览
对于var jsonData=JSON.parse(jdata.data);,我收到错误 Uncaught SyntaxError: Unexpected token o in JSON at position 1 如何解决此错误?
【问题讨论】:
-
你解析了两次,分别是
dataType: json和JSON.parse() -
@Kobe 是对的,请参阅重复的帖子。您不必要地解析 JSON 两次。
标签: javascript jquery json