|
1 | 1 | package com.fasterxml.jackson.databind.misc;
|
2 | 2 |
|
| 3 | +import java.util.List; |
| 4 | + |
3 | 5 | import com.fasterxml.jackson.annotation.JsonCreator;
|
4 | 6 | import com.fasterxml.jackson.annotation.JsonFormat;
|
5 | 7 | import com.fasterxml.jackson.annotation.JsonProperty;
|
| 8 | + |
6 | 9 | import com.fasterxml.jackson.core.JsonProcessingException;
|
| 10 | + |
7 | 11 | import com.fasterxml.jackson.databind.*;
|
8 | 12 |
|
9 | 13 | public class CaseInsensitiveDeserTest extends BaseMapTest
|
@@ -44,6 +48,51 @@ public InsensitiveCreator(@JsonProperty("value") int v0) {
|
44 | 48 | }
|
45 | 49 | }
|
46 | 50 |
|
| 51 | + // [databind#1854] |
| 52 | + static class Obj1854 { |
| 53 | + private final int id; |
| 54 | + |
| 55 | + private final List<ChildObj1854> items; |
| 56 | + |
| 57 | + public Obj1854(int id, List<ChildObj1854> items) { |
| 58 | + this.id = id; |
| 59 | + this.items = items; |
| 60 | + } |
| 61 | + |
| 62 | + @JsonCreator |
| 63 | + public static Obj1854 fromJson(@JsonProperty("ID") int id, |
| 64 | + @JsonProperty("Items") List<ChildObj1854> items) { |
| 65 | + return new Obj1854(id, items); |
| 66 | + } |
| 67 | + |
| 68 | + public int getId() { |
| 69 | + return id; |
| 70 | + } |
| 71 | + |
| 72 | + public List<ChildObj1854> getItems() { |
| 73 | + return items; |
| 74 | + } |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + // [databind#1854] |
| 79 | + static class ChildObj1854 { |
| 80 | + private final String childId; |
| 81 | + |
| 82 | + private ChildObj1854(String id) { |
| 83 | + this.childId = id; |
| 84 | + } |
| 85 | + |
| 86 | + @JsonCreator |
| 87 | + public static ChildObj1854 fromJson(@JsonProperty("ChildID") String cid) { |
| 88 | + return new ChildObj1854(cid); |
| 89 | + } |
| 90 | + |
| 91 | + public String getId() { |
| 92 | + return childId; |
| 93 | + } |
| 94 | + } |
| 95 | + |
47 | 96 | /*
|
48 | 97 | /********************************************************
|
49 | 98 | /* Test methods
|
@@ -122,4 +171,14 @@ public void testCaseInsensitiveWithClassFormat() throws Exception
|
122 | 171 | assertEquals("12", role.ID);
|
123 | 172 | assertEquals("Foo", role.Name);
|
124 | 173 | }
|
| 174 | + |
| 175 | + public void testIssue1854() throws Exception |
| 176 | + { |
| 177 | + final String DOC = aposToQuotes("{'ID': 1, 'Items': [ { 'ChildID': 10 } ]}"); |
| 178 | + Obj1854 result = INSENSITIVE_MAPPER.readValue(DOC, Obj1854.class); |
| 179 | + assertNotNull(result); |
| 180 | + assertEquals(1, result.getId()); |
| 181 | + assertNotNull(result.getItems()); |
| 182 | + assertEquals(1, result.getItems().size()); |
| 183 | + } |
125 | 184 | }
|
0 commit comments