use of jakarta.json.JsonWriterFactory in project glassfish-hk2 by eclipse-ee4j.
the class JsonParser method marshal.
/* (non-Javadoc)
* @see org.glassfish.hk2.xml.spi.XmlServiceParser#marshall(java.io.OutputStream, org.glassfish.hk2.xml.api.XmlRootHandle)
*/
@Override
public <T> void marshal(OutputStream outputStream, XmlRootHandle<T> rootHandle, Map<String, Object> options) throws IOException {
JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
T root = rootHandle.getRoot();
JsonObject rootObject = createJsonObject((BaseHK2JAXBBean) root, objectBuilder);
Map<String, Object> config = new HashMap<String, Object>();
config.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
JsonWriterFactory writerFactory = Json.createWriterFactory(config);
JsonWriter writer = writerFactory.createWriter(outputStream);
try {
writer.writeObject(rootObject);
} finally {
writer.close();
}
}
Aggregations