I am using Newtosoft.Json Library. Here is an example of my class.
public class TableItemsClass
{
public int InventoryTransTempID { get; set; }
public string Description { get; set; }
public string Extras { get; set; }
public decimal Quantity { get; set; }
public decimal ItemPrice { get; set; }
public decimal TotalPrice { get; set; }
public decimal SumPrice { get; set; }
public decimal SumDisPrice { get; set; }
public int Situation { get; set; }
public string TemporaryText { get; set; }
public bool TableIsClosed { get; set; }
public decimal KitchenQuantity { get; set; }
public string KitchenTime { get; set; }
public int InventoryItemID { get; set; }
}
I am sending my data through an http client. So i am using the function.
var jsonString1 = JsonConvert.SerializeObject(mItems);
So my question is doest it worth performance and speed, for usinge GZip after my string's serialization? Or json automatically is compressing my string when i send a request through an http Client?
var client = new HttpClient();
await client.PostAsync("https://www.ddd.com",new StringContent( jsonString1,Encoding.UTF8,"application/json"));
Does it worth to use GZip Example
var jsonString1 = Zip(JsonConvert.SerializeObject(mItems));
public static void CopyTo(Stream src, Stream dest)
{
byte[] bytes = new byte[4096];
int cnt;
while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0)
{
dest.Write(bytes, 0, cnt);
}
}
public static byte[] Zip(string str)
{
var bytes = Encoding.UTF8.GetBytes(str);
using (var msi = new MemoryStream(bytes))
using (var mso = new MemoryStream())
{
using (var gs = new GZipStream(mso, CompressionMode.Compress))
{
//msi.CopyTo(gs);
CopyTo(msi, gs);
}
return mso.ToArray();
}
}
Also is there any method to remove duplicate key values foreach property? For redusing my string's length?