This expression has type 'void' and can't be used
9,605
Checking the example in the docs for the plugin you're using, I believe that .parse
methods returns void
.
As the example shows, you should first parse
and then transform to json with one of the different methods (.toBadgerfish
, .toGData()
, toParker()
).
Hence, your code should be something like this:
Xml2Json xml2json = new Xml2Json();
xml2json.parse(data);
String json = xml2json.toBadgerfish();
Author by
Code Hunter
Updated on December 16, 2022Comments
-
Code Hunter over 1 year
I am trying to parse XML to JSON and for that I have used Xml2JSON package. When I am using this it is resulting me an error:
Error: This expression has type 'void' and can't be used.
Here is my code:
Xml2Json xml2json = new Xml2Json(); String json = xml2json.parse(data);