Hello,
I have a byte[] of a text. How can I write (incl. escaping) this to a
JsonGenerator. JsonGenerator#writeRawUTF8String(byte[] buffer, int offset,
int length) does the job, but misses escaping.
To provide further background, I am trying to serialize a stack trace to
text. But while doing so, I am using a pool of byte[] to avoid allocation.
That is,
public void resolve(Throwable throwable, JsonGenerator jsonGenerator) throws
Exception {
ByteBufferOutputStream outputStream = outputStreamPool.acquire();
try (PrintStream printStream = new PrintStream(outputStream, false,
"UTF-8")) {
exception.printStackTrace(printStream);
}
ByteBuffer outputStreamBuffer = outputStream.getByteBuffer();
jsonGenerator.writeRawUTF8String(outputStreamBuffer.array(), 0,
outputStreamBuffer.position());
outputStreamPool.release(outputStream);
}
I will appreciate any tips.
Thanks in advance.
Best.
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/55a53cdf-4910-4c58-8650-f41799e07729%40googlegroups.com.