FormatException:输入的意外结束(在字符1处)
我正在尝试从json解析数据,但是出了点问题. 终端控制台说:
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
可以在这里找到我的json:链接
My json can be found here: link
但是在这个链接上,当我尝试从json解析数据时,它可以工作,而且两个json看起来都一样. (在这一点上,我无权访问PHP文件)
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)
我像往常一样进行json打印,
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?
一直在努力解决同样的错误... 触发POST req有什么奇怪的地方,但是无论如何都抛出了异常.
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());
用于监视输出-将在今天晚上找出哪一个(可能是Map),并告知您.同时,请重新检查您的响应类型并解码-就像我的情况一样,它肯定有问题.
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.