### Question:
StringListMapDeserializer extends JsonDeserializer<Object> { @Override public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { JsonNode jsonNode = jsonParser.readValueAsTree(); Iterator<Map.Entry<String, JsonNode>> itr = jsonNode.fields(); Map<String, List<String>> map = new HashMap<>(); while (itr.hasNext()) { Map.Entry<String, JsonNode> e = itr.next(); List<String> values = new LinkedList<>(); if (!e.getValue().isArray()) { values.add((e.getValue().isNull()) ? null : e.getValue().asText()); } else { ArrayNode a = (ArrayNode) e.getValue(); Iterator<JsonNode> vitr = a.elements(); while (vitr.hasNext()) { JsonNode node = vitr.next(); values.add((node.isNull() ? null : node.asText())); } } map.put(e.getKey(), values); } return map; }  @Override Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext);  }### Answer:
@Test public void nonNullValue() throws IOException { Map<String, List<String>> attributes = deserialize("\"foo\": \"bar\""); assertTrue(attributes.containsKey("foo")); List<String> foo = attributes.get("foo"); assertEquals(1, foo.size()); assertEquals("bar", foo.get(0)); }
@Test public void nonNullValueArray() throws IOException { Map<String, List<String>> attributes = deserialize("\"foo\": [ \"bar\", \"baz\" ]"); assertTrue(attributes.containsKey("foo")); List<String> foo = attributes.get("foo"); assertEquals(2, foo.size()); assertEquals("baz", foo.get(1)); }
@Test public void nullValue() throws IOException { Map<String, List<String>> attributes = deserialize("\"foo\": null"); assertTrue(attributes.containsKey("foo")); List<String> foo = attributes.get("foo"); assertEquals(1, foo.size()); assertNull(foo.get(0)); }
@Test public void nullValueArray() throws IOException { Map<String, List<String>> attributes = deserialize("\"foo\": [ null, \"something\", null ]"); assertTrue(attributes.containsKey("foo")); List<String> foo = attributes.get("foo"); assertEquals(3, foo.size()); assertEquals("something", foo.get(1)); assertNull(foo.get(2)); }