Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/main/java/tools/jackson/core/json/JsonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,32 @@ public JsonFactoryBuilder rebuild() {

/**
* Main factory method to use for constructing {@link JsonFactory} instances with
* different configuration.
*
* different configuration. The builder returned uses default settings more closely
* matched the default configs used in Jackson 2.x versions.
* <p>
* This method is still a work in progress and may not yet fully replicate the
* default settings of Jackson 2.x.
* </p>
* @return Builder instance to use
*/
public static JsonFactoryBuilder builder() {
return new JsonFactoryBuilder();
}

/**
* Factory method to use for constructing {@link JsonFactory} instances with
* different configuration.
*
* @return Builder instance to use
*/
public static JsonFactoryBuilder builderWithJackson2Defaults() {
return builder()
.disable(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)
.disable(JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8)
.disable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
.disable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER);
}

/**
* Method for constructing a new {@link JsonFactory} that has
* the same settings as this instance, but is otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ public void testCanonicalizationDisabled() throws Exception {
doCanonicalizationTest(false);
}

@Test
public void testBuilderWithJackson2Defaults() {
JsonFactory factory = JsonFactory.builderWithJackson2Defaults().build();
assertFalse(factory.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER));
assertFalse(factory.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
assertFalse(factory.isEnabled(JsonWriteFeature.ESCAPE_FORWARD_SLASHES));
assertFalse(factory.isEnabled(JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8));
}

// Configure the JsonFactory as expected, and verify across common shapes of input
// to cover common JsonParser implementations.
private void doCanonicalizationTest(boolean canonicalize) throws Exception {
Expand Down