try {
if (formatExtension.equalsIgnoreCase("xml")) {
newLayer = (TileLayer) xs.fromXML(is);
} else if (formatExtension.equalsIgnoreCase("json")) {
HierarchicalStreamDriver driver = new JettisonMappedXmlDriver();
HierarchicalStreamReader hsr = driver.createReader(is);
// See http://jira.codehaus.org/browse/JETTISON-48
StringWriter writer = new StringWriter();
new HierarchicalStreamCopier().copy(hsr, new PrettyPrintWriter(writer));
writer.close();
newLayer = (TileLayer) xs.fromXML(writer.toString());