Unexpected end of JSON input

JSON.parse()参数不能为空,否则会报错 Unexpected end of JSON input

解决:JSON.parse(JSON.stringify(xxx))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: "unexpected end of json input"错误通常是由于JSON数据格式不完整或解析错误导致的。根据您提供的引用内容,可能有以下几个原因导致这个错误的出现。引用中提到,当使用JSON.parse()时,括号里的值不能为空。如果值为空,就会报错。另外,引用指出,如果JSON数据中包含特殊字符(如问号、和&符号),在传递参数前需要使用JSON.stringify转换为字符串,并使用encodeURIComponent进行编码。接收数据时,需要先使用decodeURIComponent进行解码,然后再使用JSON.parse将其转换为JSON格式的对象或数组。因此,您可以检查您的代码,确保JSON数据格式完整,并根据需要进行相应的编码和解码操作,以避免"unexpected end of json input"错误的发生。123 #### 引用[.reference_title] - *1* [解析JSON报错Unexpected end of JSON input](https://blog.csdn.net/qq_45610622/article/details/128255271)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *2* *3* [解决Unexpected end of JSON input 报错](https://blog.csdn.net/qq_41288473/article/details/122964895)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值