@@ -42,7 +42,7 @@ public void testSerializationOrder() throws Exception {
42
42
NestedRecordTwo nestedRecordTwo = new NestedRecordTwo ("2" , "111110" );
43
43
NestedRecordOne nestedRecordOne =
new NestedRecordOne (
"1" ,
"[email protected] " ,
nestedRecordTwo );
44
44
final String output = MAPPER .writeValueAsString (nestedRecordOne );
45
- final String expected =
"{ \" email\" : \" [email protected] \" , \" id \" : \" 1 \" , \" nestedRecordTwo\" :{ \" id \" : \" 2 \" , \" passport\" : \" 111110\" }}";
45
+ final String expected =
a2q ( "{'id':'1',' email':' [email protected] ',' nestedRecordTwo':{'id':'2',' passport':' 111110' }}") ;
46
46
assertEquals (expected , output );
47
47
}
48
48
@@ -52,7 +52,7 @@ public void testSerializationOrderWithJsonProperty() throws Exception {
52
52
NestedRecordOneWithJsonProperty nestedRecordOne =
53
53
new NestedRecordOneWithJsonProperty (
"1" ,
"[email protected] " ,
nestedRecordTwo );
54
54
final String output = MAPPER .writeValueAsString (nestedRecordOne );
55
- final String expected =
"{ \" email\" : \" [email protected] \" , \" id \" : \" 1 \" , \" nestedProperty\" :{ \" id \" : \" 2 \" , \" passport\" : \" 111110\" }}";
55
+ final String expected =
a2q ( "{'id':'1',' email':' [email protected] ',' nestedProperty':{'id':'2',' passport':' 111110' }}") ;
56
56
assertEquals (expected , output );
57
57
}
58
58
@@ -79,21 +79,14 @@ public void testSerializationOrderWithJsonPropertyOrder() throws Exception {
79
79
// [databind#4580]
80
80
@ Test
81
81
public void testSerializationOrderWrtCreatorAlphabetic () throws Exception {
82
- // In 3.0, sorting by Alphabetic enabled by default so
83
- assertEquals (a2q ("{'a':'a','b':'b','c':'c'}" ),
84
- MAPPER .writeValueAsString (new CABRecord ("c" , "a" , "b" )));
85
- // But can disable
82
+ // In 3.0, sorting by Alphabetic enabled by default BUT it won't affect Creator props
86
83
assertEquals (a2q ("{'c':'c','a':'a','b':'b'}" ),
84
+ MAPPER .writeValueAsString (new CABRecord ("c" , "a" , "b" )));
85
+ // Unless we disable Creator-props-first setting:
86
+ assertEquals (a2q ("{'a':'a','b':'b','c':'c'}" ),
87
87
jsonMapperBuilder ()
88
- .disable (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
88
+ .disable (MapperFeature .SORT_CREATOR_PROPERTIES_FIRST )
89
89
.build ()
90
90
.writeValueAsString (new CABRecord ("c" , "a" , "b" )));
91
- // Except if we tell it not to:
92
- assertEquals (a2q ("{'c':'c','a':'a','b':'b'}" ),
93
- jsonMapperBuilder ()
94
- .enable (MapperFeature .SORT_PROPERTIES_ALPHABETICALLY )
95
- .enable (MapperFeature .SORT_CREATOR_PROPERTIES_BY_DECLARATION_ORDER )
96
- .build ()
97
- .writeValueAsString (new CABRecord ("c" , "a" , "b" )));
98
91
}
99
92
}
0 commit comments