File tree 2 files changed +32
-2
lines changed
main/java/com/fasterxml/jackson/databind/introspect
test/java/com/fasterxml/jackson/databind/deser
2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -322,9 +322,10 @@ public AnnotatedMember findAnySetterAccessor() throws IllegalArgumentException
322
322
// For now let's require a Map; in future can add support for other
323
323
// types like perhaps Iterable<Map.Entry>?
324
324
Class <?> type = anyField .getRawType ();
325
- if (!Map .class .isAssignableFrom (type )) {
325
+ if (!Map .class .isAssignableFrom (type )
326
+ && !JsonNode .class .isAssignableFrom (type )) {
326
327
throw new IllegalArgumentException (String .format (
327
- "Invalid 'any-setter' annotation on field '%s': type is not instance of java.util.Map" ,
328
+ "Invalid 'any-setter' annotation on field '%s': type is not instance of ` java.util.Map` or `JsonNode` " ,
328
329
anyField .getName ()));
329
330
}
330
331
return anyField ;
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .databind .deser ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonAnySetter ;
4
+
5
+ import com .fasterxml .jackson .databind .*;
6
+
7
+ // for [databind#3394]
8
+ public class AnySetter3394Test extends BaseMapTest
9
+ {
10
+ static class AnySetter3394Bean {
11
+ @ JsonAnySetter
12
+ public JsonNode extraData ;
13
+ }
14
+
15
+ /*
16
+ /**********************************************************
17
+ /* Test methods
18
+ /**********************************************************
19
+ */
20
+
21
+ private final ObjectMapper MAPPER = newJsonMapper ();
22
+
23
+ public void testAnySetterWithJsonNode () throws Exception
24
+ {
25
+ final String DOC = a2q ("{'test': 3}" );
26
+ AnySetter3394Bean bean = MAPPER .readValue (DOC , AnySetter3394Bean .class );
27
+ assertEquals (DOC , "" +bean .extraData );
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments