此表达式的类型为 'void',无法使用
This expression has type 'void' and can't be used
我正在尝试将 XML 解析为 JSON,为此我使用了 Xml2JSON 包。当我使用它时,它导致我出错:
Error: This expression has type 'void' and can't be used.
这是我的代码:
Xml2Json xml2json = new Xml2Json();
String json = xml2json.parse(data);
正在检查 the example in the docs 您正在使用的插件,我相信 .parse
方法 returns void
.
如示例所示,您应该首先 parse
,然后使用不同方法之一转换为 json(.toBadgerfish
、.toGData()
、toParker()
).
因此,您的代码应该是这样的:
Xml2Json xml2json = new Xml2Json();
xml2json.parse(data);
String json = xml2json.toBadgerfish();
我正在尝试将 XML 解析为 JSON,为此我使用了 Xml2JSON 包。当我使用它时,它导致我出错:
Error: This expression has type 'void' and can't be used.
这是我的代码:
Xml2Json xml2json = new Xml2Json();
String json = xml2json.parse(data);
正在检查 the example in the docs 您正在使用的插件,我相信 .parse
方法 returns void
.
如示例所示,您应该首先 parse
,然后使用不同方法之一转换为 json(.toBadgerfish
、.toGData()
、toParker()
).
因此,您的代码应该是这样的:
Xml2Json xml2json = new Xml2Json();
xml2json.parse(data);
String json = xml2json.toBadgerfish();