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