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

Commit

Permalink
Merge pull request #12 from stevenschlansker/breaks-map-deserialization
Browse files Browse the repository at this point in the history
Show that deserializing Map<String, Object> breaks :(
  • Loading branch information
cowtowncoder committed Mar 21, 2014
2 parents 3adf8d6 + 2c2e0eb commit a00ebcb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ public JavaType resolveAbstractType(DeserializationConfig config, JavaType type)
/* We won't be handling any container types (Collections, Maps and arrays),
* Throwables or enums.
*/
if (type.isContainerType() || type.isPrimitive() || type.isEnumType() || type.isThrowable()) {
if (type.isContainerType() || type.isPrimitive() || type.isEnumType() || type.isThrowable() ||
type.getRawClass() == Number.class)
{
return null;
}
Class<?> cls = type.getRawClass();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.fasterxml.jackson.module.mrbean;

import java.io.IOException;
import java.util.Collections;
import java.util.Map;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class TestMapStringObjectDeserialization
extends BaseTest
{

/**
* Test simple Map deserialization works.
*/
public void testMapWithMrbean() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new MrBeanModule());

runTest(mapper);
}

/**
* Test simple Map deserialization works.
*/
public void testMapWithoutMrbean() throws Exception
{
ObjectMapper mapper = new ObjectMapper();

runTest(mapper);
}

void runTest(ObjectMapper mapper) throws IOException, JsonParseException, JsonMappingException
{
Map<String, Object> map = mapper.readValue("{\"test\":3 }", new TypeReference<Map<String, Object>>() {});
assertEquals(Collections.singletonMap("test", 3), map);
}
}

0 comments on commit a00ebcb

Please sign in to comment.