【问题标题】:Firebase Database full JSON to List - FlutterFirebase 数据库完整 JSON 列表 - Flutter
【发布时间】:2021-01-18 20:28:52
【问题描述】:

我正在将一个 Json 文件从本地磁盘加载到我的颤振项目中名为 mydata 的列表中:

    String jsonfile;    
    jsonfile = "assets/derechopenal.json"

    future: DefaultAssetBundle.of(context).loadString(jsonfile, cache: false),
      builder: (context, snapshot) {
        List mydata = json.decode(snapshot.data.toString());
    
     return testpage(mydata: mydata)
                                   }

如果现在将这个 json 文件上传到 firebase 数据库,我该如何以同样的方式获取它?

https://opositestgc.firebaseio.com/derechopenal

我已经添加了所有需要的依赖项和包,as seen here 并且我卡在代码请求中。谢谢

【问题讨论】:

    标签: json database firebase flutter http


    【解决方案1】:

    适用于 Flutter 的 Firebase 实时数据库 SDK 不返回原始 JSON 数据,而是返回表示基础数据的对象模型。因此,如果您使用 SDK,则必须使用 example for the library 中所示的对象模型。

    如果您想坚持使用原始 JSON,可以使用REST API to access the Firebase Database。这将返回原始 JSON,然后您可以继续使用该文件中的 JSON。

    【讨论】:

      猜你喜欢
      • 2017-11-30
      • 2021-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      • 1970-01-01
      • 2022-08-05
      • 1970-01-01
      相关资源
      最近更新 更多