【问题标题】:This expression has type 'void' and can't be used此表达式的类型为“void”,不能使用
【发布时间】:2019-12-06 09:55:58
【问题描述】:

我正在尝试将 XML 解析为 JSON,为此我使用了 Xml2JSON 包。当我使用它时,它会导致我出现错误:

Error: This expression has type 'void' and can't be used.

这是我的代码:

Xml2Json xml2json = new Xml2Json();
String json = xml2json.parse(data);

【问题讨论】:

    标签: xml flutter dart xml-parsing


    【解决方案1】:

    检查您正在使用的插件的the example in the docs,我相信.parse 方法返回void

    如示例所示,您应先parse,然后使用不同方法之一(.toBadgerfish.toGData()toParker())转换为 json。

    因此,您的代码应该是这样的:

    Xml2Json xml2json = new Xml2Json();
    xml2json.parse(data);
    String json = xml2json.toBadgerfish();
    

    【讨论】:

      猜你喜欢
      • 2023-02-23
      • 2022-09-23
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-31
      • 1970-01-01
      • 2021-09-09
      相关资源
      最近更新 更多