@Test public void testWriteSampleType() throws Exception { JsonXMLObjectProvider provider = new JsonXMLObjectProvider(null); Annotation[] annotations = new Annotation[]{JsonXMLDefault.class.getAnnotation(JsonXML.class)}; SampleType sampleType = new SampleType(); sampleType.element = "hi!"; StringWriter writer = new StringWriter(); provider.write(SampleType.class, null, annotations, MediaType.APPLICATION_JSON_TYPE, null, writer, sampleType); String json = "{\"sampleType\":{\"element\":\"hi!\"}}"; Assert.assertEquals(json, writer.toString()); }
@Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object value) throws IOException, WebApplicationException { JsonXML config = getJsonXML(type, annotations); try { writeObject(type, config, getContext(type, mediaType), stream, value); } catch (XMLStreamException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } catch (JAXBException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } }
JsonXMLObjectProvider extends AbstractJsonXMLProvider { @Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object value) throws IOException, WebApplicationException { JsonXML config = getJsonXML(type, annotations); try { writeObject(type, config, getContext(type, mediaType), stream, value); } catch (XMLStreamException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } catch (JAXBException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } } }
JsonXMLObjectProvider extends AbstractJsonXMLProvider { @Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object value) throws IOException, WebApplicationException { JsonXML config = getJsonXML(type, annotations); try { writeObject(type, config, getContext(type, mediaType), stream, value); } catch (XMLStreamException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } catch (JAXBException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } } JsonXMLObjectProvider(@Context Providers providers); }
JsonXMLObjectProvider extends AbstractJsonXMLProvider { @Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object value) throws IOException, WebApplicationException { JsonXML config = getJsonXML(type, annotations); try { writeObject(type, config, getContext(type, mediaType), stream, value); } catch (XMLStreamException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } catch (JAXBException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } } JsonXMLObjectProvider(@Context Providers providers); @Override Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader stream); @Override void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer stream,
			Object value); }
JsonXMLObjectProvider extends AbstractJsonXMLProvider { @Override public void write( Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, Writer stream, Object value) throws IOException, WebApplicationException { JsonXML config = getJsonXML(type, annotations); try { writeObject(type, config, getContext(type, mediaType), stream, value); } catch (XMLStreamException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } catch (JAXBException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } } JsonXMLObjectProvider(@Context Providers providers); @Override Object read(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders,
			Reader stream); @Override void write(
			Class<?> type,
			Type genericType,
			Annotation[] annotations,
			MediaType mediaType,
			MultivaluedMap<String, Object> httpHeaders,
			Writer stream,
			Object value);  }