Skip to content

Commit 50e3005

Browse files
authored
1 parent 2b43b5d commit 50e3005

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberDeserTest.java

+92
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.StringReader;
55
import java.math.BigDecimal;
66
import java.math.BigInteger;
7+
import java.util.Arrays;
78
import java.util.List;
89
import java.util.Map;
910

@@ -110,6 +111,79 @@ static DecimalHolder4917 of(BigDecimal value) {
110111
}
111112
}
112113

114+
static class Point {
115+
private Double x;
116+
private Double y;
117+
118+
public Double getX() {
119+
return x;
120+
}
121+
122+
public void setX(Double x) {
123+
this.x = x;
124+
}
125+
126+
public Double getY() {
127+
return y;
128+
}
129+
130+
public void setY(Double y) {
131+
this.y = y;
132+
}
133+
}
134+
135+
@JsonTypeInfo(
136+
use = JsonTypeInfo.Id.NAME,
137+
include = JsonTypeInfo.As.EXISTING_PROPERTY,
138+
property = "type",
139+
visible = true)
140+
@JsonSubTypes(@JsonSubTypes.Type(value = CenterResult.class, name = "center"))
141+
static abstract class Result {
142+
private String type;
143+
144+
public String getType() {
145+
return type;
146+
}
147+
148+
public void setType(String type) {
149+
this.type = type;
150+
}
151+
}
152+
153+
static class CenterResult extends Result {
154+
private Point center;
155+
156+
private Double radius;
157+
158+
public Double getRadius() {
159+
return radius;
160+
}
161+
162+
public void setRadius(Double radius) {
163+
this.radius = radius;
164+
}
165+
166+
public Point getCenter() {
167+
return center;
168+
}
169+
170+
public void setCenter(Point center) {
171+
this.center = center;
172+
}
173+
}
174+
175+
static class Root {
176+
private Result[] results;
177+
178+
public Result[] getResults() {
179+
return results;
180+
}
181+
182+
public void setResults(Result[] results) {
183+
this.results = results;
184+
}
185+
}
186+
113187
/*
114188
/**********************************************************************
115189
/* Helper classes, serializers/deserializers/resolvers
@@ -470,4 +544,22 @@ public void bigDecimal4917V3() throws Exception
470544
assertEquals(new BigDecimal("100.00"), issue.decimal);
471545
assertEquals(50, issue.number);
472546
}
547+
548+
// https://github.com/FasterXML/jackson-core/issues/1397
549+
@Test
550+
public void issue1397() throws Exception {
551+
final String dataString = a2q("{ 'results': [ { " +
552+
"'radius': 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, " +
553+
"'type': 'center', " +
554+
"'center': { " +
555+
"'x': -11.0, " +
556+
"'y': -2.0 } } ] }");
557+
558+
Root object = MAPPER.readValue(dataString, Root.class);
559+
560+
CenterResult result = (CenterResult) Arrays.stream(object.getResults()).findFirst().get();
561+
562+
assertEquals(-11.0d, result.getCenter().getX());
563+
assertEquals(-2.0d, result.getCenter().getY());
564+
}
473565
}

0 commit comments

Comments
 (0)