@Override public void writeTo( Object o, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { outputStream.write(GlobalGson.get().toJson(o).getBytes(this.utf8)); }
@Override public Object readFrom( Class<Object> objectClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream inputStream) throws IOException, WebApplicationException { StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, this.utf8); String jsonString = writer.toString(); return GlobalGson.get().fromJson(jsonString, objectClass); }