【发布时间】:2019-06-19 08:33:26
【问题描述】:
我正在使用Dio 发出HTTP 请求
var dio = Dio();
var response =
await dio.get(URL);
final responseBody = json.decode(response.data);
final statusCode = response.statusCode;
if (statusCode != 200 || responseBody == null) {
print("status code:$statusCode");
throw new ServerExceptionHandler(
"An error ocurred : [Status Code : $statusCode]", statusCode);
}
我正在处理的响应
{
"x_id": "home"
}
但是json.decode(response.data) 正在抛出异常。
type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
奇怪的是,当我将 Dio 替换为 http.get(url) 然后 json.decode(response.body) 与相同的响应完美配合
【问题讨论】:
-
看看this是否有帮助。
-
试过不行
-
您能提供您想要获取的网址吗?或者至少可以使用邮递员获取 json e 将其格式化为您的问题?
-
更新了 JSON 响应
-
好的,知道了。写下我的答案。
标签: android json http dart flutter