NodeMapper { @SuppressWarnings("unchecked") public <T extends Map, U, V extends Map<String, ? extends U>> V deserializeMap( Node value, Class<T> into, Class<U> members ) { return (V) deserializeNext(value, "", into, members, this); }  void setSerializeNullValues(boolean serializeNullValues); boolean getSerializeNullValues(); void setWhenMissingSetter(WhenMissing whenMissing); WhenMissing getWhenMissingSetter(); void disableToNodeForClass(Class type); void enableToNodeForClass(Class type); Set<Class> getDisableToNode(); void disableFromNodeForClass(Class type); void enableFromNodeForClass(Class type); Set<Class> getDisableFromNode(); boolean getOmitEmptyValues(); void setOmitEmptyValues(boolean omitEmptyValues); Node serialize(Object object); T deserialize(Node value, Class<T> into); T deserializeInto(Node value, T objectToMutate); @SuppressWarnings("unchecked") V deserializeCollection(
            Node value,
            Class<T> into,
            Class<U> members
    ); @SuppressWarnings("unchecked") V deserializeMap(
            Node value, Class<T> into,
            Class<U> members
    );  }
@Test public void deserializedIntoMap() { Node heterogeneous = Node.parse("{\"foo\":\"foo\",\"baz\":10}"); Node homogeneous = Node.parse("{\"foo\":\"foo\",\"baz\":\"baz\"}"); NodeMapper mapper = new NodeMapper(); Map<String, Object> heterogeneousMap = mapper.deserializeMap(heterogeneous, Map.class, Object.class); Map<String, String> homogeneousMap = mapper.deserializeMap(homogeneous, TreeMap.class, String.class); assertThat(heterogeneousMap, instanceOf(HashMap.class)); assertThat(homogeneousMap, instanceOf(TreeMap.class)); assertThat(homogeneousMap, hasKey("foo")); assertThat(heterogeneousMap, hasKey("foo")); assertThat(homogeneousMap, hasKey("baz")); assertThat(heterogeneousMap, hasKey("baz")); assertThat(homogeneousMap.get("foo"), equalTo("foo")); assertThat(heterogeneousMap.get("foo"), equalTo("foo")); assertThat(homogeneousMap.get("baz"), equalTo("baz")); assertThat(heterogeneousMap.get("baz"), equalTo(10L)); }
@Test public void dealsWithInvalidMapTypes() { Node object = Node.objectNode().withMember("foo", 10); NodeMapper mapper = new NodeMapper(); NodeDeserializationException e = Assertions.assertThrows( NodeDeserializationException.class, () -> mapper.deserializeMap(object, Map.class, String.class)); assertThat(e.getMessage(), equalTo( "Deserialization error at (/foo): unable to create java.lang.String from 10")); }