List of usage examples for com.fasterxml.jackson.dataformat.xml XmlMapper writerWithDefaultPrettyPrinter
public ObjectWriter writerWithDefaultPrettyPrinter()
From source file:com.blockwithme.lessobjects.util.JSONParser.java
/** * To xml string./*from w w w .j ava 2s . c o m*/ * * @return the string */ @SuppressWarnings("null") public String toXMLString() { if (xmlString == null) { if (!fromSchema) { try { final XmlMapper mapper = new XmlMapper(); xmlString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); } catch (final JsonProcessingException jpe) { throw new IllegalStateException(jpe.getMessage(), jpe); } } else { try { if (format == SchemaFormat.JSON) { if (jsonString == null) { jsonString = jsonOrXMLString; } schema = getBinding(); xmlString = new XmlMapper().writerWithDefaultPrettyPrinter().writeValueAsString(schema); } else { xmlString = jsonOrXMLString; } } catch (final IOException e) { throw new IllegalStateException(e.getMessage(), e); } } } return xmlString; }