Skip to content

Commit

Permalink
Faster Jackson default settings
Browse files Browse the repository at this point in the history
By default Jackson does not enable faster features to ensure 100% backwards compatibility. They should be safe and are already in use by many projects.

Note that `USE_FAST_DOUBLE_WRITER` has been ported to Java 20 and so has been left out. Maybe something for the avaje native json to consider if not already (use built-in instead of custom)?
  • Loading branch information
re-thc committed Oct 4, 2024
1 parent 0a0ad75 commit 26125dc
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.avaje.jsonb.jackson;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.StreamReadFeature;
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import io.avaje.jsonb.JsonIoException;
Expand Down Expand Up @@ -101,7 +102,10 @@ public Builder failOnUnknown(boolean failOnUnknown) {
*/
public JacksonAdapter build() {
if (jsonFactory == null) {
jsonFactory = new JsonFactory();
jsonFactory = JsonFactory.builder()
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
.build();
}
return new JacksonAdapter(serializeNulls, serializeEmpty, failOnUnknown, jsonFactory);
}
Expand All @@ -118,7 +122,7 @@ public JacksonAdapter build() {
public JacksonAdapter() {
this(false, false, false, new JsonFactory());
}


public JacksonAdapter(JsonFactory factory) {
this(false, false, false, factory);
Expand Down

0 comments on commit 26125dc

Please sign in to comment.