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

Commit d94738f

Browse files
author
Steven Schlansker
committed
Show that deserializing Map<String, Object> breaks :(
1 parent 3adf8d6 commit d94738f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
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)