code: @Override
      public void doSerialize( JsonWriter writer, I values, JsonSerializationContext ctx, JsonSerializerParameters params ) {
          Iterator<T> iterator = values.iterator();
  
          if ( !iterator.hasNext() ) {
              if ( ctx.isWriteEmptyJsonArrays() ) {
                  writer.beginArray();
                  writer.endArray();
              } else {
                  writer.cancelName();
              }
              return;
          }
  
          if ( ctx.isWriteSingleElemArraysUnwrapped() ) {
  
              T first = iterator.next();
  
              if ( iterator.hasNext() ) {
                  // there is more than one element, we write the array normally
                  writer.beginArray();
                  serializer.serialize( writer, first, ctx, params );
                  while ( iterator.hasNext() ) {
                      serializer.serialize( writer, iterator.next(), ctx, params );
                  }
                  writer.endArray();
              } else {
                  // there is only one element, we write it directly
                  serializer.serialize( writer, first, ctx, params );
              }
  
          } else {
              writer.beginArray();
              while ( iterator.hasNext() ) {
                  serializer.serialize( writer, iterator.next(), ctx, params );
              }
              writer.endArray();
          }
      }
docs: {@inheritDoc}