|
1 | 1 | package com.fasterxml.jackson.databind.deser.filter;
|
2 | 2 |
|
| 3 | +import java.io.IOException; |
| 4 | + |
3 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
4 | 6 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
| 7 | + |
5 | 8 | import com.fasterxml.jackson.databind.BaseMapTest;
|
6 | 9 | import com.fasterxml.jackson.databind.ObjectMapper;
|
7 | 10 |
|
@@ -35,6 +38,22 @@ static class Simple1595 {
|
35 | 38 | public void setName(String name) { this.name = name; }
|
36 | 39 | }
|
37 | 40 |
|
| 41 | + // [databind#2627] |
| 42 | + |
| 43 | + @JsonIgnoreProperties(ignoreUnknown = true) |
| 44 | + static class MyPojoValue { |
| 45 | + @JsonIgnoreProperties(ignoreUnknown = true) |
| 46 | + MyPojo2627 value; |
| 47 | + |
| 48 | + public MyPojo2627 getValue() { |
| 49 | + return value; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + static class MyPojo2627 { |
| 54 | + public String name; |
| 55 | + } |
| 56 | + |
38 | 57 | /*
|
39 | 58 | /****************************************************************
|
40 | 59 | /* Unit tests
|
@@ -88,4 +107,16 @@ public void testIgnoreGetterNotSetter1595() throws Exception
|
88 | 107 | Simple1595 des = mapper.readValue(aposToQuotes("{'id':123,'name':'jack'}"), Simple1595.class);
|
89 | 108 | assertEquals("jack", des.getName());
|
90 | 109 | }
|
| 110 | + |
| 111 | + // [databind#2627] |
| 112 | + public void testIgnoreUnknownOnField() throws IOException |
| 113 | + { |
| 114 | + ObjectMapper objectMapper = new ObjectMapper(); |
| 115 | + String json = "{\"value\": {\"name\": \"my_name\", \"extra\": \"val\"}, \"type\":\"Json\"}"; |
| 116 | + MyPojoValue value = objectMapper.readValue(json, MyPojoValue.class); |
| 117 | + assertNotNull(value); |
| 118 | + assertNotNull(value.getValue()); |
| 119 | + assertEquals("my_name", value.getValue().name); |
| 120 | + } |
91 | 121 | }
|
| 122 | + |
0 commit comments