【问题标题】:Display the complete json data from API response in flutter在 Flutter 中显示来自 API 响应的完整 json 数据
【发布时间】:2021-06-20 02:35:24
【问题描述】:

我从 API 调用中获取 json 数据,但它没有显示完整的数据。有很多属性可以使用,创建模型会很困难,因为这是我第一次使用任何 API。所以我想使用 app.quicktype.io 将 json 数据直接解析为我需要获取完整 json 数据的 dart 代码。现在控制台中只显示了一小部分 json 数据。

代码:

Future<void> getContacts() async {
    var client = http.Client();
    String contacts_url =
        'https://mylinkexample.com';
    String basicAuth =
        'Basic mykeyexampele';
    var response = await client.get(contacts_url,
        headers: <String, String>{'authorization': basicAuth});
    var jsonString = jsonDecode(response.body);
    print(response.statusCode);
    print(jsonString);
  }

【问题讨论】:

  • 您是通过 POSTMAN 验证还是直接验证来自后端的响应带来了所有信息?,因为它可能没有从后端带来所有信息。
  • 您可以添加输出的屏幕截图以及它的外观吗?

标签: json api flutter dart rest


【解决方案1】:

使用这个:

import 'dart:developer' as developer;

test() {
  developer.log(response.body);
}

【讨论】:

    猜你喜欢
    • 2021-10-17
    • 1970-01-01
    • 2021-10-03
    • 2022-01-13
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 2022-12-23
    • 2020-12-10
    相关资源
    最近更新 更多