[未处理的承诺拒绝:语法错误:JSON 解析错误:无法识别的令牌]



我只想在react原生错误中映射一个JSON数据,但我得到的错误是"[未处理的承诺拒绝:SyntaxError:JSON分析错误:无法识别的令牌'']"用JSON.parse.解析后

axios.get("http://www.upclass.com.hk/api.php?apicall=getcustomer").then((e) => {
var res = JSON.parse(e.data)
console.log("New Data =>", res);
this.setState({
data: res
});
});

这是JSON数据

{
"id": "D6C9C876-CDA2-4C27-85BF-276D3035D762",
"fullname": null,
"username": null,
"email": "mohssssin@gmail.com",
"areaid": null,
"aid": null,
"mobile": "123456",
"photoid": null,
"imagepath": null,
"lang": "zh",
"custgroup": "P         ",
"IsVolunteer": null,
"notification": "Y",
"createdate": "2021-03-26 19:05:02.290",
"updatedate": null,
"otherarea": null
}

尝试JsonConvert.DeserializeObject而不是Parse。你可以在这里查看

最新更新