|
6 | 6 |
|
7 | 7 | import com.fasterxml.jackson.annotation.JsonInclude;
|
8 | 8 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
| 9 | +import com.fasterxml.jackson.annotation.JsonTypeInfo; |
| 10 | +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; |
| 11 | +import com.fasterxml.jackson.annotation.JsonTypeName; |
9 | 12 | import com.fasterxml.jackson.core.*;
|
10 | 13 | import com.fasterxml.jackson.databind.*;
|
11 | 14 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
@@ -117,6 +120,11 @@ public NoEmptyStringsMap add(String key, String value) {
|
117 | 120 | }
|
118 | 121 | }
|
119 | 122 |
|
| 123 | + // for [databind#691] |
| 124 | + @JsonTypeInfo(use=Id.NAME) |
| 125 | + @JsonTypeName("mymap") |
| 126 | + static class MapWithTypedValues extends LinkedHashMap<String,String> { } |
| 127 | + |
120 | 128 | /*
|
121 | 129 | /**********************************************************
|
122 | 130 | /* Test methods
|
@@ -255,4 +263,17 @@ public void testClassKey() throws IOException
|
255 | 263 | String json = MAPPER.writeValueAsString(map);
|
256 | 264 | assertEquals(aposToQuotes("{'java.lang.String':2}"), json);
|
257 | 265 | }
|
| 266 | + |
| 267 | + // [databind#691] |
| 268 | + public void testNullJsonMapping691() throws Exception |
| 269 | + { |
| 270 | + MapWithTypedValues input = new MapWithTypedValues(); |
| 271 | + input.put("id", "Test"); |
| 272 | + input.put("NULL", null); |
| 273 | + |
| 274 | + String json = MAPPER.writeValueAsString(input); |
| 275 | + |
| 276 | + assertEquals(aposToQuotes("{'@type':'mymap','id':'Test','NULL':null}"), |
| 277 | + json); |
| 278 | + } |
258 | 279 | }
|
0 commit comments