Skip to content

Commit 687f46b

Browse files
committed
Fix json-snapshot#27: Lib can not be used with Jackson 2.10.0 or later
1 parent 3c00008 commit 687f46b

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353
<dependency>
5454
<groupId>com.fasterxml.jackson.core</groupId>
5555
<artifactId>jackson-core</artifactId>
56-
<version>2.9.8</version>
56+
<version>2.12.3</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>com.fasterxml.jackson.core</groupId>
6060
<artifactId>jackson-databind</artifactId>
61-
<version>2.9.10.7</version>
61+
<version>2.12.3</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>org.projectlombok</groupId>
@@ -236,4 +236,4 @@
236236
</plugin>
237237
</plugins>
238238
</build>
239-
</project>
239+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.github.jsonSnapshot;
2+
3+
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
4+
import com.fasterxml.jackson.core.util.Separators;
5+
6+
public class CustomDefaultPrettyPrinter extends DefaultPrettyPrinter {
7+
public CustomDefaultPrettyPrinter(String s) {
8+
super(s);
9+
}
10+
11+
@Override
12+
public DefaultPrettyPrinter withSeparators(Separators separators) {
13+
this._separators = separators;
14+
this._objectFieldValueSeparatorWithSpaces = separators.getObjectFieldValueSeparator() + " ";
15+
return this;
16+
}
17+
18+
@Override
19+
public DefaultPrettyPrinter createInstance() {
20+
return new DefaultPrettyPrinter(this);
21+
}
22+
}

src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,7 @@ static Function<Object, String> defaultJsonFunction() {
129129

130130
private static PrettyPrinter buildDefaultPrettyPrinter() {
131131
DefaultPrettyPrinter pp =
132-
new DefaultPrettyPrinter("") {
133-
@Override
134-
public DefaultPrettyPrinter withSeparators(Separators separators) {
135-
this._separators = separators;
136-
this._objectFieldValueSeparatorWithSpaces =
137-
separators.getObjectFieldValueSeparator() + " ";
138-
return this;
139-
}
140-
};
132+
new CustomDefaultPrettyPrinter("");
141133
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n");
142134
pp.indentArraysWith(lfOnlyIndenter);
143135
pp.indentObjectsWith(lfOnlyIndenter);

0 commit comments

Comments
 (0)