Sunday, January 29, 2017

.NET JsonContent for HttpClient

.NET already comes with a nice collection of HttpContent serializers, but it lacks a JsonContent type. A common solution is to just serialize their payload to a JSON string and that insert that into an instance of StringContent. However, this means that you need to remember to set your headers, and it is a little bit inefficient because of how it creates multiple strings and buffers for each payload.

I have create a simple implementation of JsonContent that uses Json.NET and pooled memory streams. The result is between 2% and 10% faster, and causes ~50% fewer garbage collections.

Check out the implementation in Tact.NET:

Enjoy,
Tom

11 comments:

  1. Wow! This blog looks exactly like my old one! It’s on a totally different subject but it has pretty much the same layout and design. Superb choice of colors!

    성인야설
    대딸방
    스포츠마사지
    건전마사지
    카지노

    ReplyDelete
  2. I am really happy with your blog because your article is very unique and powerful for new. . I want share about Aaraa couture

    ReplyDelete
  3. Amazing blog! I really like the way you explained such information about this post to us. And a blog is really helpful for us this website.
    LastPass Password Generator Crack
    UltraMixer Crack
    Luminar Crack
    Tenorshare 4uKey Crack
    UltraISO Crack
    Camtasia Studio Crack
    NTLite Crack
    iMazing Crack
    downloadpc.co

    ReplyDelete
  4. Thank you so much for your excellent blog! I really enjoy to visit your very interesting post, Well done!
    Family Lawyer Cost
    Female Family Lawyer Near Me

    ReplyDelete
  5. Nice piece of information. Kindly check out my new blog Monosnap Serial Key 2023

    ReplyDelete
  6. Looking for solutions to fix QuickBooks Error H202? Connect with experts at toll- free number +1(855)-955-1942 and get the error resolved.

    ReplyDelete
  7. Well-written information. Very impressive and to the point
    Have a look at my new blog:Adobe Media Encoder Crack 2024

    ReplyDelete

Real Time Web Analytics