Friday 4 April 2014

JSON to XML and XML to JSON in JAVA




Best So far for JSON and XML conversions:

As we all know that  now a days we are some how touches the JSON for webapps or standalone applications.

I have requirement where people are asking for JSON to Object and Object to JSON. For this we have lot more easy ways to convert . But for the JSON to XML and vice-versa, we don’t have much options with attribute and XML standards  support.

I found some solutions which need 5-6 jar dependencies and some attribute problems. And XML standard problems. I also fed up with weird tags like  "<e" . Tried and invested couple of hours for better solution and came up with this below one.

This is very simple and easy to understand , for quick reference please check the ref URL .

Finally I am very much satisfied with simple solution like "Staxon".


Very soon I will provide the working example Which I used .

StAXON - JSON via StAX
StAXON lets you read and write JSON using the Java Streaming API for XML (javax.xml.stream). StAXON acts as a door opener for JSON to powerful XML related technologies like
  • XSL transformations (XSLT)
  • XML binding API (JAXB)
  • XML Schema Definition (XSD)
  • XPath, XQuery, ...
Features
  • Support for JAXB and JAX-RS
  • Trigger JSON arrays via XML processing instruction
  • Full XML namespace support
  • Support the JSON Processing API (JSR-353), Jackson and Gson as JSON streaming backends
  • Memory efficient, even for very large documents
Documentation
Check the Getting Started guide first. More documentation is available from the StAXON Wiki.
Downloads
The Downloads page provides Maven instructions and individual download links.

No comments:

Post a Comment

Please comment here