I found that many of the tutorials on the net and here on SO also refer to net.sf.json library to convert an xml file to 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?
I've done the same using JAXB to convert my xml to an object, and passing the object to gson. I know it takes one additional step, but that worked convenient for me. Upon converting xml to jaxb see also: Use JAXB to create Object from XML String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With