Skip to content

Commit

Permalink
Fix json-snapshot#27: Lib can not be used with Jackson 2.10.0 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
Euklios committed Jun 17, 2021
1 parent 3c00008 commit 687f46b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.8</version>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.7</version>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -236,4 +236,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.github.jsonSnapshot;

import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.core.util.Separators;

public class CustomDefaultPrettyPrinter extends DefaultPrettyPrinter {
public CustomDefaultPrettyPrinter(String s) {
super(s);
}

@Override
public DefaultPrettyPrinter withSeparators(Separators separators) {
this._separators = separators;
this._objectFieldValueSeparatorWithSpaces = separators.getObjectFieldValueSeparator() + " ";
return this;
}

@Override
public DefaultPrettyPrinter createInstance() {
return new DefaultPrettyPrinter(this);
}
}
10 changes: 1 addition & 9 deletions src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,7 @@ static Function<Object, String> defaultJsonFunction() {

private static PrettyPrinter buildDefaultPrettyPrinter() {
DefaultPrettyPrinter pp =
new DefaultPrettyPrinter("") {
@Override
public DefaultPrettyPrinter withSeparators(Separators separators) {
this._separators = separators;
this._objectFieldValueSeparatorWithSpaces =
separators.getObjectFieldValueSeparator() + " ";
return this;
}
};
new CustomDefaultPrettyPrinter("");
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n");
pp.indentArraysWith(lfOnlyIndenter);
pp.indentObjectsWith(lfOnlyIndenter);
Expand Down

0 comments on commit 687f46b

Please sign in to comment.