简体   繁体   English

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

[英]FormatException: Unexpected end of input (at character 1)

I'm trying to parse data from json but something is wrong.我正在尝试从 json 解析数据,但出了点问题。 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我的 json 可以在这里找到: 链接

But at this link it works when I try to parse data from json, and both json's looks same.但是在此链接中,当我尝试从 json 解析数据时它会起作用,并且两个 json 看起来都相同。 ( at this one I do not have access to PHP file) (在此我无权访问 PHP 文件)

I did json print as usually, like this:我像往常一样进行 json 打印,如下所示:

$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?我错过了什么吗?

been struggling wit the same error since yesterday... whats strange that POST req is fired, but the exception was thrown anyway..自昨天以来一直在为同样的错误而苦苦挣扎...... POST req 被触发有什么奇怪的,但无论如何还是抛出了异常......

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.同时重新检查您的响应类型和解码 - 就像我的情况一样,它一定有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 formatexception (formatexception: 意外字符 (在字符 1) json - formatexception (formatexception: unexpected character (at character 1) json 未处理的异常:FormatException:意外字符(在字符 1 处)Flutter - Unhandled Exception: FormatException: Unexpected character (at character 1) Flutter Flutter 未处理异常:FormatException:意外字符(在字符 4) - Flutter Unhandled Exception: FormatException: Unexpected character (at character 4) flutter:FormatException:意外字符(在字符 1 处) <br> ^: flutter 与 phpmyadmin - flutter: FormatException: Unexpected character (at character 1) <br /> ^: flutter with phpmyadmin 输入信号的意外结束 - Unexpected end of input moodle JSON输入意外结束 - Unexpected end of JSON input 输入中的意外字符:“ \\” - Unexpected character in input: '\' I/flutter (27225): FormatException: 意外字符(在字符 1) I/flutter (27225):<br> 我/颤振(27225):^ - I/flutter (27225): FormatException: Unexpected character (at character 1) I/flutter (27225): <br /> I/flutter (27225): ^ 未处理的异常:FormatException:意外字符(在字符 1 处)E/flutter(6084):<br /> E/颤振(6084):^ - Unhandled Exception: FormatException: Unexpected character (at character 1) E/flutter ( 6084): <br /> E/flutter ( 6084): ^ JSONException输入的第0个字符的结尾 - JSONException End of input at character 0 of
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM