Skip to content
Merged
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 @@ -353,48 +353,6 @@ protected Object _deserializeFP(JsonParser p, DeserializationContext ctxt)
}
return p.getDoubleValue();
}

// NOTE: copied from above (alas, no easy way to share/reuse)
// @since 2.12 (wrt [databind#2733]
protected Object _mapObjectWithDups(JsonParser p, DeserializationContext ctxt,
final Map<String, Object> result, String initialKey,
Object oldValue, Object newValue, String nextKey)
throws JacksonException
{
final boolean squashDups = ctxt.isEnabled(StreamReadCapability.DUPLICATE_PROPERTIES);

if (squashDups) {
_squashDups(result, initialKey, oldValue, newValue);
}

while (nextKey != null) {
p.nextToken();
newValue = deserialize(p, ctxt);
oldValue = result.put(nextKey, newValue);
if ((oldValue != null) && squashDups) {
_squashDups(result, nextKey, oldValue, newValue);
}
nextKey = p.nextName();
}

return result;
}

// NOTE: copied from above (alas, no easy way to share/reuse)
@SuppressWarnings("unchecked")
private void _squashDups(final Map<String, Object> result, String key,
Object oldValue, Object newValue)
{
if (oldValue instanceof List<?>) {
((List<Object>) oldValue).add(newValue);
result.put(key, oldValue);
} else {
ArrayList<Object> l = new ArrayList<>();
l.add(oldValue);
l.add(newValue);
result.put(key, l);
}
}

/*
/**********************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ static class StringStringMap extends LinkedHashMap<String,String> { };
private final String DOC_WITH_DUPS = a2q(
"{'hello': 'world',\n"
+ "'lists' : 1,\n"
+ "'lists' : 2,\n"
+ "'lists' : 2.5,\n"
+ "'lists' : {\n"
+ " 'inner' : 'internal',\n"
+ " 'time' : 123\n"
+ "},\n"
+ "'lists' : 3,\n"
+ "'single' : 'one'\n"
+ "'lists' : true,\n"
+ "'single' : 'one',\n"
+ "'lists' : false,\n"
+ "'lists' : null\n"
+ "}");

// Testing the baseline non-merging behavior
Expand Down Expand Up @@ -84,7 +86,7 @@ private <T> void _verifyDupsNoMerging(Class<T> cls) throws Exception

String json = JSON_MAPPER.writeValueAsString(value);
assertEquals(a2q(
"{'hello':'world','lists':3,'single':'one'}"),
"{'hello':'world','lists':null,'single':'one'}"),
json);
}

Expand All @@ -94,8 +96,8 @@ private <T> void _verifyDupsNoMerging(Class<T> cls) throws Exception
private void _verifyDupsAreMerged(Class<?> cls) throws Exception
{
assertEquals(a2q(
"{'hello':'world','lists':[1,2,"
+"{'inner':'internal','time':123},3],'single':'one'}"),
"{'hello':'world','lists':[1,2.5,"
+"{'inner':'internal','time':123},true,false,null],'single':'one'}"),
_readWriteDupDoc(DOC_WITH_DUPS, cls));
}

Expand Down
Loading