@@ -233,7 +233,6 @@ protected ArrayNode _withArrayAddTailProperty(JsonPointer tail, boolean preferIn
233
233
return putObject (propName )._withArrayAddTailProperty (tail , preferIndex );
234
234
}
235
235
236
-
237
236
/*
238
237
/**********************************************************
239
238
/* Overrides for JsonSerializable.Base
@@ -489,24 +488,25 @@ public List<JsonNode> findParents(String propertyName, List<JsonNode> foundSoFar
489
488
*/
490
489
@ SuppressWarnings ("deprecation" )
491
490
@ Override
492
- public void serialize (JsonGenerator g , SerializerProvider provider )
491
+ public void serialize (JsonGenerator g , SerializerProvider ctxt )
493
492
throws IOException
494
493
{
495
- if (provider != null ) {
496
- boolean trimEmptyArray = !provider .isEnabled (SerializationFeature .WRITE_EMPTY_JSON_ARRAYS );
497
- boolean skipNulls = !provider .isEnabled (JsonNodeFeature .WRITE_NULL_PROPERTIES );
494
+ if (ctxt != null ) {
495
+ boolean trimEmptyArray = !ctxt .isEnabled (SerializationFeature .WRITE_EMPTY_JSON_ARRAYS );
496
+ boolean skipNulls = !ctxt .isEnabled (JsonNodeFeature .WRITE_NULL_PROPERTIES );
498
497
if (trimEmptyArray || skipNulls ) {
499
498
g .writeStartObject (this );
500
- serializeFilteredContents (g , provider , trimEmptyArray , skipNulls );
499
+ serializeFilteredContents (g , ctxt , trimEmptyArray , skipNulls );
501
500
g .writeEndObject ();
502
501
return ;
503
502
}
504
503
}
505
- g .writeStartObject (this );
506
- for (Map .Entry <String , JsonNode > en : _contentsToSerialize (provider ).entrySet ()) {
507
- JsonNode value = en .getValue ();
504
+ Map <String , JsonNode > contents = _contentsToSerialize (ctxt );
505
+ // 25-Apr-2025, tatu: [databind#5103] Pass size (some formats can optimize)
506
+ g .writeStartObject (this , contents .size ());
507
+ for (Map .Entry <String , JsonNode > en : contents .entrySet ()) {
508
508
g .writeFieldName (en .getKey ());
509
- value . serialize (g , provider );
509
+ en . getValue (). serialize (g , ctxt );
510
510
}
511
511
g .writeEndObject ();
512
512
}
0 commit comments