【问题标题】:Flutter json response using Dio使用 Dio 颤振 json 响应
【发布时间】:2021-04-12 01:20:06
【问题描述】:

我有一个简单的 response.data 让我{消息:您已成功签入}

var dio = Dio();
Response response = await dio.get('http://10.0.2.2:4000/');
print(response.data); //{message: You have checked in successfully}

我怎样才能打印出:您已成功签入?使用 print(response.data.message) 将不起作用。

【问题讨论】:

    标签: json flutter dio


    【解决方案1】:

    使用以下代码将您的 response.data 转换为 Map

     Map result = response.data;
     print(result['message']);
    

    【讨论】:

      猜你喜欢
      • 2021-09-08
      • 1970-01-01
      • 2021-06-10
      • 2022-06-28
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多