-
-
Notifications
You must be signed in to change notification settings - Fork 823
Description
We have a JsonGenerator on a Writer. We would like to write Java 8 Date Time values to JSON. We would like to do so by avoiding intermediate objects and garbage like the String object but instead directly render to the Writer. At first we thought we could achieve this as DateTimeFormatter allows appending to a Appendable and Writer implement Appendable. We thought that by implementing SerializableString we could achieve this. Unfortunately this does not work as WriterBasedJsonGenerator#writeString(SerializableString) always creates a char[] intermediate object. This is in contrast to UTF8JsonGenerator#writeString(SerializableString) which allows directly rendering to the output buffer without creating intermediate objects/garbage.
Ideally the SerializableString would be changed but in your case the intended outcome would be achieved if WriterBasedJsonGenerator#writeString would call #appendQuoted(char[], int) instead.
This is with Jackson 2.9.6.