code: @Override
      public void doSerialize( JsonWriter writer, C values, JsonSerializationContext ctx, JsonSerializerParameters params ) {
          if ( values.isEmpty() ) {
              if ( ctx.isWriteEmptyJsonArrays() ) {
                  writer.beginArray();
                  writer.endArray();
              } else {
                  writer.cancelName();
              }
              return;
          }
  
          if ( ctx.isWriteSingleElemArraysUnwrapped() && values.size() == 1 ) {
              // there is only one element, we write it directly
              serializer.serialize( writer, values.iterator().next(), ctx, params );
          } else {
              writer.beginArray();
              for ( T value : values ) {
                  serializer.serialize( writer, value, ctx, params );
              }
              writer.endArray();
          }
      }
docs: {@inheritDoc}