-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#patch: Fixes #162 - Stable formatting between Jackson 2.16 and earli…
…er versions Unfortunatily this reaches even deeper into Jackson internals than before, so it might break in the future (again). On the other hand, this sidesteps messing with reflection or other hacks to decide on which version of Jackson we are currently running.
- Loading branch information
Showing
3 changed files
with
28 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...n/src/main/java/au/com/origin/snapshots/jackson/serializers/v1/SnapshotPrettyPrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package au.com.origin.snapshots.jackson.serializers.v1; | ||
|
||
import com.fasterxml.jackson.core.util.DefaultIndenter; | ||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; | ||
|
||
class SnapshotPrettyPrinter extends DefaultPrettyPrinter { | ||
|
||
public SnapshotPrettyPrinter() { | ||
super(""); | ||
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n"); | ||
this.indentArraysWith(lfOnlyIndenter); | ||
this.indentObjectsWith(lfOnlyIndenter); | ||
|
||
this._objectFieldValueSeparatorWithSpaces = | ||
this._separators.getObjectFieldValueSeparator() + " "; | ||
} | ||
|
||
// It's a requirement | ||
// @see https://github.com/FasterXML/jackson-databind/issues/2203 | ||
public DefaultPrettyPrinter createInstance() { | ||
return new DefaultPrettyPrinter(this); | ||
} | ||
} |