@@ -40,6 +40,12 @@ public static JsonSerializer<Object> getStdKeySerializer(SerializationConfig con
40
40
if (rawKeyType == String .class ) {
41
41
return DEFAULT_STRING_SERIALIZER ;
42
42
}
43
+ if ((rawKeyType == Integer .class ) || (rawKeyType == Integer .TYPE )) {
44
+ return new Default (Default .TYPE_INTEGER , rawKeyType );
45
+ }
46
+ if ((rawKeyType == Long .class ) || (rawKeyType == Long .TYPE )) {
47
+ return new Default (Default .TYPE_LONG , rawKeyType );
48
+ }
43
49
if (rawKeyType .isPrimitive () || Number .class .isAssignableFrom (rawKeyType )) {
44
50
// 28-Jun-2016, tatu: Used to just return DEFAULT_KEY_SERIALIZER, but makes
45
51
// more sense to use simpler one directly
@@ -121,7 +127,9 @@ public static class Default extends StdSerializer<Object> {
121
127
final static int TYPE_CALENDAR = 2 ;
122
128
final static int TYPE_CLASS = 3 ;
123
129
final static int TYPE_ENUM = 4 ;
124
- final static int TYPE_TO_STRING = 5 ;
130
+ final static int TYPE_INTEGER = 5 ; // since 2.9
131
+ final static int TYPE_LONG = 6 ; // since 2.9
132
+ final static int TYPE_TO_STRING = 7 ;
125
133
126
134
protected final int _typeId ;
127
135
@@ -149,6 +157,10 @@ public void serialize(Object value, JsonGenerator g, SerializerProvider provider
149
157
g .writeFieldName (str );
150
158
}
151
159
break ;
160
+ case TYPE_INTEGER :
161
+ case TYPE_LONG :
162
+ g .writeFieldId (((Number ) value ).longValue ());
163
+ break ;
152
164
case TYPE_TO_STRING :
153
165
default :
154
166
g .writeFieldName (value .toString ());
0 commit comments