Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,11 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
return ctxt.handleUnexpectedToken(Object.class, p);
}

@Override
public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException {
return new Object();
}

@Override
public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.fasterxml.jackson.databind.deser.filter;

import java.util.*;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.InvalidNullException;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;

// For [databind#1402]; configurable null handling, for contents of
// Collections, Maps, arrays
public class NullConversionsForContentTest extends BaseMapTest
Expand Down Expand Up @@ -297,6 +300,15 @@ public void testNullsAsEmptyWithMaps() throws Exception
assertEquals(ABC.A, result.values.entrySet().iterator().next().getKey());
assertEquals("", result.values.entrySet().iterator().next().getValue());
}

// Then: Map<String,Object>
{
NullContentAsEmpty<Map<String,Object>> result
= MAPPER.readValue(MAP_JSON, new TypeReference<NullContentAsEmpty<Map<String,Object>>>() { });
assertEquals(1, result.values.size());
assertEquals("A", result.values.entrySet().iterator().next().getKey());
assertNotNull(result.values.entrySet().iterator().next().getValue());
}
}

/*
Expand Down