@Override
protected void writeTo(Object t, MediaType mediaType, Charset c,
Marshaller m, OutputStream entityStream)
throws JAXBException, IOException {
if (m instanceof JSONMarshaller) {
JSONMarshaller jm = (JSONMarshaller)m;
jm.setJsonEnabled(true);
jm.marshal(t,
new OutputStreamWriter(entityStream, c));
} else {
m.marshal(t, JsonXmlStreamWriter.createWriter(
new OutputStreamWriter(entityStream, c), true));
}