json - [未处理的承诺拒绝:SyntaxError: JSON Parse error: Unrecognized token '']
问题描述
我只想在反应本机错误中映射一个 JSON 数据,但是在用 JSON.parse 解析它之后,我收到错误“[Unhandled promise reject: SyntaxError: JSON Parse error: Unrecognized token '']”。
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。你可以在这里查看
推荐阅读
- javascript - TypeError:无法读取未定义的属性“bulkDelete”
- python - Python中的三重嵌套字典到数据框
- stored-procedures - 多个会话执行雪花程序插入到同一个表中
- swift - 无法从字典中提取数据
迅速 - ruby-on-rails - RAILS 版本不一致
- vb.net - 使用定制的画笔在 Picturboxes 中创建填充正方形并从列表中提取
- c# - 在 BLE GATT 配置文件中,字符是否真的被读取或写入?
- flutter - 您不能以 root 身份运行 CocoaPods。(CLAide::Help) 颤振
- docker - 如果相应的服务具有构建上下文部分,则 docker-compose 不会提取图像
- vue.js - (Vue3) [Vue 警告]:在渲染期间访问了属性“...”,但未在实例上定义。在
类绑定时出错