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


Underscore-java can convert xml to json. You can call the U.xmlToJson (xml) method. I support the project.



0


source


Has anyone found any other solution without using another third party library, how can we achieve XML for gson JsonObject?

-1


source







All Articles