|
4 | 4 | import java.io.StringReader;
|
5 | 5 | import java.math.BigDecimal;
|
6 | 6 | import java.math.BigInteger;
|
| 7 | +import java.util.Arrays; |
7 | 8 | import java.util.List;
|
8 | 9 | import java.util.Map;
|
9 | 10 |
|
@@ -110,6 +111,79 @@ static DecimalHolder4917 of(BigDecimal value) {
|
110 | 111 | }
|
111 | 112 | }
|
112 | 113 |
|
| 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 | + |
113 | 187 | /*
|
114 | 188 | /**********************************************************************
|
115 | 189 | /* Helper classes, serializers/deserializers/resolvers
|
@@ -470,4 +544,22 @@ public void bigDecimal4917V3() throws Exception
|
470 | 544 | assertEquals(new BigDecimal("100.00"), issue.decimal);
|
471 | 545 | assertEquals(50, issue.number);
|
472 | 546 | }
|
| 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 | + } |
473 | 565 | }
|
0 commit comments