douli1306 2019-03-26 22:47
浏览 860
已采纳

FormatException:意外的输入结束(在字符1处)

I'm trying to parse data from json but something is wrong. Terminal console says:

Performing hot restart...
Restarted application in 1.659ms.
I/flutter ( 9594): Load xd en
I/flutter ( 9594): Exception: FormatException: Unexpected end of input (at character 1)
I/flutter ( 9594):
I/flutter ( 9594): ^
I/flutter ( 9594): /0
I/flutter ( 9594): error: 0

My json can be found here: link

But at this link it works when I try to parse data from json, and both json's looks same. ( at this one I do not have access to PHP file)

I did json print as usually, like this:

$myJson = ['op'=>true,'msg'=>'','data'=>['pages'=>3538,'page'=>(int)$stranica,'news'=>$api]];
        print_r(json_encode($myJson));

Is there any trick/hack about this? Am I missing something?

  • 写回答

1条回答 默认 最新

  • dopq87915 2019-03-28 12:59
    关注

    been struggling wit the same error since yesterday... whats strange that POST req is fired, but the exception was thrown anyway..

    in my case, the problem was one of the temporary functions returning the response:

    //      Response registerResponse = await dio.post(Strings.USER_REGISTER_URL, data: requestBody, options: new Options(contentType: ContentType("application", "json")));
    
    
    //      print(TAG + registerResponse.toString());
    //      print(TAG + registerResponse.data.toString());
    //      Map<String, dynamic> parsedregisterResponse = jsonDecode(registerResponse.data);
    //      print(TAG + "response: " + parsedregisterResponse.toString());
    

    used to monitor the output - will find out which one (probably Map) this evening and let u know. In the meantime recheck your response type and decoding -there must be something wrong with it just like in my case.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致
  • ¥150 求 《小魔指》街机游戏机整合模拟软件