@Override public void writeToWriter(Object model, Writer writer) throws IOException { ((JsonValue)model).writeTo(writer); }
/** * Writes the JSON representation of this value to the given writer in its minimal form, without * any additional whitespace. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer * the writer to write this value to * @throws IOException * if an I/O error occurs in the writer */ public void writeTo(Writer writer) throws IOException { writeTo(writer, WriterConfig.MINIMAL); }
/** * Returns the JSON string for this value using the given formatting. * * @param config * a configuration that controls the formatting or <code>null</code> for the minimal form * @return a JSON string that represents this value */ public String toString(WriterConfig config) { StringWriter writer = new StringWriter(); try { writeTo(writer, config); } catch (IOException exception) { // StringWriter does not throw IOExceptions throw new RuntimeException(exception); } return writer.toString(); }
/** * Writes the JSON representation of this value to the given writer in its minimal form, without * any additional whitespace. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer * the writer to write this value to * @throws IOException * if an I/O error occurs in the writer */ public void writeTo(Writer writer) throws IOException { writeTo(writer, WriterConfig.MINIMAL); }
/** * Writes the JSON representation of this value to the given writer in its minimal form, without * any additional whitespace. * <p> * Writing performance can be improved by using a {@link java.io.BufferedWriter BufferedWriter}. * </p> * * @param writer * the writer to write this value to * @throws IOException * if an I/O error occurs in the writer */ public void writeTo(Writer writer) throws IOException { writeTo(writer, WriterConfig.MINIMAL); }
/** * Returns the JSON string for this value using the given formatting. * * @param config * a configuration that controls the formatting or <code>null</code> for the minimal form * @return a JSON string that represents this value */ public String toString(WriterConfig config) { StringWriter writer = new StringWriter(); try { writeTo(writer, config); } catch (IOException exception) { // StringWriter does not throw IOExceptions throw new RuntimeException(exception); } return writer.toString(); }
/** * Returns the JSON string for this value using the given formatting. * * @param config * a configuration that controls the formatting or <code>null</code> for the minimal form * @return a JSON string that represents this value */ public String toString(WriterConfig config) { StringWriter writer = new StringWriter(); try { writeTo(writer, config); } catch (IOException exception) { // StringWriter does not throw IOExceptions throw new RuntimeException(exception); } return writer.toString(); }
public String toString(PrintMode printMode) { StringWriter sw = new StringWriter(); try { switch (printMode) { case REGULAR: Json.parse(toString()).writeTo(sw, PrettyPrint.singleLine()); break; case PRETTY: Json.parse(toString()).writeTo(sw, WriterConfig.PRETTY_PRINT); break; default: return toString(); } } catch (IOException e) {} return sw.toString(); }
public String toString(PrintMode printMode) { StringWriter sw = new StringWriter(); try { switch (printMode) { case REGULAR: Json.parse(toString()).writeTo(sw, PrettyPrint.singleLine()); break; case PRETTY: Json.parse(toString()).writeTo(sw, WriterConfig.PRETTY_PRINT); break; default: return toString(); } } catch (IOException e) {} return sw.toString(); }
public String toString(PrintMode printMode) { StringWriter sw = new StringWriter(); try { switch (printMode) { case REGULAR: Json.parse(toString()).writeTo(sw, PrettyPrint.singleLine()); break; case PRETTY: Json.parse(toString()).writeTo(sw, WriterConfig.PRETTY_PRINT); break; default: return toString(); } } catch (IOException e) {} return sw.toString(); }
public String toString(PrintMode printMode) { StringWriter sw = new StringWriter(); try { switch (printMode) { case REGULAR: Json.parse(toString()).writeTo(sw, PrettyPrint.singleLine()); break; case PRETTY: Json.parse(toString()).writeTo(sw, WriterConfig.PRETTY_PRINT); break; default: return toString(); } } catch (IOException e) {} return sw.toString(); }
@Benchmark @Override public Object minimaljson() throws Exception { ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(baos); JSON_SOURCE().streamSerializer().minimaljson(JSON_SOURCE().nextPojo()).writeTo(writer); writer.close(); return baos; }
unflattened.writeTo(sw, getWriterConfig()); } catch (IOException e) {} return sw.toString();
unflattened.writeTo(sw, getWriterConfig()); } catch (IOException e) {} return sw.toString();