@@ -36,6 +36,25 @@ public Bean(int a, int b, Map<String,Object> x) {
3636 public Map <String ,Object > getExtra () { return extra ; }
3737 }
3838
39+ @ JsonPropertyOrder (alphabetic = true )
40+ static class AnyGetterBeforeFieldsBean
41+ {
42+ public int x ;
43+
44+ protected Map <String ,Object > extra = new HashMap <>();
45+
46+ public int y ;
47+
48+ public AnyGetterBeforeFieldsBean (int x , int y , Map <String ,Object > a ) {
49+ this .x = x ;
50+ this .y = y ;
51+ extra = a ;
52+ }
53+
54+ @ JsonAnyGetter
55+ public Map <String ,Object > getExtra () { return extra ; }
56+ }
57+
3958 /*
4059 /**********************************************************
4160 /* Test methods
@@ -44,7 +63,6 @@ public Bean(int a, int b, Map<String,Object> x) {
4463
4564 private final ObjectMapper MAPPER = newJsonMapper ();
4665
47- @ JacksonTestFailureExpected
4866 @ Test
4967 void anyBeanWithSort () throws Exception
5068 {
@@ -54,4 +72,14 @@ void anyBeanWithSort() throws Exception
5472 String json = MAPPER .writeValueAsString (new Bean (1 , 2 , extra ));
5573 assertEquals (a2q ("{'a':1,'b':2,'x':3,'y':4}" ), json );
5674 }
75+
76+ @ Test
77+ void anyGetterSortingBeforeFields () throws Exception
78+ {
79+ Map <String ,Object > extra = new LinkedHashMap <>();
80+ extra .put ("b" , 4 );
81+ extra .put ("a" , 3 );
82+ String json = MAPPER .writeValueAsString (new AnyGetterBeforeFieldsBean (1 , 2 , extra ));
83+ assertEquals (a2q ("{'a':3,'b':4,'x':1,'y':2}" ), json );
84+ }
5785}
0 commit comments