Converting XML file to Json using Gson
I found that many of the tutorials on the net and here at SO also refer to a library net.sf.json
for converting an xml file to a json object.
But, I want an alternative, preferably using Gson. Is it possible? I don't have well-defined Java classes for the XML file. But I just want to convert the xml file to com.google.gson.JsonObject
. How to achieve it?
+4
source to share
3 answers
I did the same using JAXB to convert my xml to object and pass the gson object. I know it takes one more step, but it worked for me. After converting xml to jaxb see also: Use JAXB to Create Object from XML String
+1
source to share