@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
/** * Returns a function (writer) converting {@link JsonStructure} to the {@link Flow.Publisher Publisher} * of {@link DataChunk}s. * * @param charset a charset to use or {@code null} for default charset * @return created function */ public Function<JsonStructure, Flow.Publisher<DataChunk>> writer(Charset charset) { return json -> { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JsonWriter writer = (charset == null) ? jsonWriterFactory.createWriter(baos) : jsonWriterFactory.createWriter(baos, charset); writer.write(json); writer.close(); return ContentWriters.byteArrayWriter(false) .apply(baos.toByteArray()); }; }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public void writeTo(JsonValue jsonValue, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : writeTo", getClass().getName()); JsonWriter writer = findWriter(mediaType, entityStream); try { writer.write(jsonValue); } finally { writer.close(); } }
@Override public void writeTo(JsonStructure jsonStructure, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : writeTo", getClass().getName()); JsonWriter writer = findWriter(mediaType, entityStream); try { writer.write(jsonStructure); } finally { writer.close(); } } }
@Override protected void doWrite(final JsonWriter writer, final JsonStructure structure) { writer.write(structure); } }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public String toString() { StringWriter sw = new StringWriter(); try (JsonWriter jw = new JsonWriterImpl(sw, bufferPool)) { jw.write(this); } return sw.toString(); }
@Override public void writeTo(JsonValue jsonValue, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream outputStream) throws IOException, WebApplicationException { try (JsonWriter writer = wf.createWriter(outputStream)) { writer.write(jsonValue); } } }
public String to(DocStructure userObject) { if (!initialized) { throw new IllegalStateException("The system is not initialized"); } StringWriter stringWriter = new StringWriter(100); JsonWriter writer = Json.createWriter(stringWriter); JsonObject jsonStructure = (JsonObject) userObject.accept(TO_JSON, colSchema); writer.write(jsonStructure); return stringWriter.toString(); }
@Override public String toString() { StringWriter sw = new StringWriter(); JsonWriter jw = new JsonWriterImpl(sw, bufferPool); jw.write(this); jw.close(); return sw.toString(); } }
@Override public RequestBody set(final JsonStructure json) { final StringWriter writer = new StringWriter(); Json.createWriter(writer).write(json); return this.set(writer.toString()); }
/** * Print JSON. * @param src Source * @return JSON * @throws IOException If fails */ private static byte[] print(final RsJson.Source src) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (JsonWriter writer = Json.createWriter(baos)) { writer.write(src.toJson()); } return baos.toByteArray(); }
@Override public String toString() { StringWriter sw = new StringWriter(); JsonWriter jw = new JsonWriterImpl(sw, bufferPool); jw.write(this); jw.close(); return sw.toString(); } }
private static byte[] serialize(final JsonObject jsonObject) { try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) { final Map<String, ?> config = singletonMap(JsonGenerator.PRETTY_PRINTING, true); final JsonWriter jsonWriter = Json.createWriterFactory(config).createWriter(output); jsonWriter.write(jsonObject); jsonWriter.close(); return output.toByteArray(); } catch (IOException e) { throw new RuntimeException("Could not write Swagger output", e); } }
private static byte[] serialize(final JsonObject jsonObject) { try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) { final Map<String, ?> config = singletonMap(JsonGenerator.PRETTY_PRINTING, true); final JsonWriter jsonWriter = Json.createWriterFactory(config).createWriter(output); jsonWriter.write(jsonObject); jsonWriter.close(); return output.toByteArray(); } catch (IOException e) { throw new RuntimeException("Could not write Swagger output", e); } }
@Override public void writeTo(T o, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4, MultivaluedMap<String, java.lang.Object> arg5, OutputStream out) throws IOException, WebApplicationException { JsonValue jv = converter.convert(o).to(JsonValue.class); try (JsonWriter jw = Json.createWriter(out)) { jw.write(jv); } }