Skip to content
Java JSON to XML converter
Find file
Pull request Compare This branch is 36 commits behind lukas-krecan:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Java Json to XML conversion

Json2Xml project is a simple implementetion of JSON to XML conversion. Under the hood it uses Jackson pull parser and generates XML SAX events. This way the conversion has low memory consumption and is pretty fast.

There is already Jettison project that has similar objective, unfortunately it can not handle JSON arrays properly.

Json2Xml converts the following JSON



<?xml version="1.0" encoding="UTF-8"?>


If you have SAX content handler, you can use net.javacrumbs.json2xml.JsonSaxAdapter class directly.

ContentHandler ch = ...;
JsonSaxAdapter adapter = new JsonSaxAdapter(json, ch);

Otherwise it's possible to use net.javacrumbs.json2xml.JsonXmlReader together with standard Java transformation.

Transformer transformer = TransformerFactory.newInstance().newTransformer();
InputSource source = new InputSource(...);
Result result = ...;
transformer.transform(new SAXSource(new JsonXmlReader(),source), result);


To use it with Maven, just add this dependency

Something went wrong with that request. Please try again.