public String marshal(Object jaxbBean) { try { final ByteArrayOutputStream os = new ByteArrayOutputStream(); if (prettyPrint) { jsonProvider.enable(SerializationConfig.Feature.INDENT_OUTPUT, true); } jsonProvider.writeTo(jaxbBean, jaxbBean.getClass(), null, null, MediaType.APPLICATION_JSON_TYPE, null, os); // The encoding used inside JacksonJsonProvider is always UTF-8 return new String(os.toByteArray(), JsonEncoding.UTF8.getJavaName()); } catch (IOException e) { throw new JsonMarshallingException(e); } }
@Override public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { if (jaxbProvider.isWriteable(type, genericType, annotations, mediaType)) { jaxbProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } else { pojoProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } } }
public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { delegate.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); }
public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { delegate.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); }
public static void write(Object object, OutputStream out) throws IOException { createProvider().writeTo(object, object.getClass(), object.getClass(), null, MediaType.APPLICATION_JSON_TYPE, null, out); }
@Override public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { if (jaxbProvider.isWriteable(type, genericType, annotations, mediaType)) { jaxbProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } else { pojoProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } } }
@Override public void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { if (jaxbProvider.isWriteable(type, genericType, annotations, mediaType)) { jaxbProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } else { pojoProvider.writeTo(t, type, genericType, annotations, mediaType, httpHeaders, entityStream); } } }