Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit a00ebcb

Browse files
committed
Merge pull request #12 from stevenschlansker/breaks-map-deserialization
Show that deserializing Map<String, Object> breaks :(
2 parents 3adf8d6 + 2c2e0eb commit a00ebcb

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/main/java/com/fasterxml/jackson/module/mrbean/AbstractTypeMaterializer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ public JavaType resolveAbstractType(DeserializationConfig config, JavaType type)
180180
/* We won't be handling any container types (Collections, Maps and arrays),
181181
* Throwables or enums.
182182
*/
183-
if (type.isContainerType() || type.isPrimitive() || type.isEnumType() || type.isThrowable()) {
183+
if (type.isContainerType() || type.isPrimitive() || type.isEnumType() || type.isThrowable() ||
184+
type.getRawClass() == Number.class)
185+
{
184186
return null;
185187
}
186188
Class<?> cls = type.getRawClass();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.fasterxml.jackson.module.mrbean;
2+
3+
import java.io.IOException;
4+
import java.util.Collections;
5+
import java.util.Map;
6+
7+
import com.fasterxml.jackson.core.JsonParseException;
8+
import com.fasterxml.jackson.core.type.TypeReference;
9+
import com.fasterxml.jackson.databind.JsonMappingException;
10+
import com.fasterxml.jackson.databind.ObjectMapper;
11+
12+
public class TestMapStringObjectDeserialization
13+
extends BaseTest
14+
{
15+
16+
/**
17+
* Test simple Map deserialization works.
18+
*/
19+
public void testMapWithMrbean() throws Exception
20+
{
21+
ObjectMapper mapper = new ObjectMapper();
22+
mapper.registerModule(new MrBeanModule());
23+
24+
runTest(mapper);
25+
}
26+
27+
/**
28+
* Test simple Map deserialization works.
29+
*/
30+
public void testMapWithoutMrbean() throws Exception
31+
{
32+
ObjectMapper mapper = new ObjectMapper();
33+
34+
runTest(mapper);
35+
}
36+
37+
void runTest(ObjectMapper mapper) throws IOException, JsonParseException, JsonMappingException
38+
{
39+
Map<String, Object> map = mapper.readValue("{\"test\":3 }", new TypeReference<Map<String, Object>>() {});
40+
assertEquals(Collections.singletonMap("test", 3), map);
41+
}
42+
}

0 commit comments

Comments
 (0)