using ICSharpCode.SharpZipLib.GZip;
using System.Diagnostics;
public static void Main()
Trace.WriteLine("****************SharpZipLib Test*****************************");
""objectId"": ""bbad4cc8-bce8-438e-8683-3e603d746dee"",
""timestamp"": ""2021-04-28T14:02:42.247Z"",
""variable"": ""temperatureArray"",
""model"": ""abc.abcdefg.abcdef"",
""value"": [ 43.471600438222104, 10.00940101687303, 39.925500606152, 32.34369812176735, 33.07786476010357 ]
var ipStringSize = Encoding.UTF8.GetByteCount(text);
var compressedString = CompressString(text);
var opStringSize = compressedString.Length;
float stringCompressionRatio = (float)opStringSize / ipStringSize;
Console.WriteLine("String Compression Ratio using SharpZipLib " + stringCompressionRatio);
public static byte[] CompressString(string text)
if (string.IsNullOrEmpty(text))
byte[] buffer = Encoding.UTF8.GetBytes(text);
using (var compressedStream = new MemoryStream())
GZip.Compress(new MemoryStream(buffer), compressedStream, false);
byte[] compressedData = compressedStream.ToArray();