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. https://www.omgab.com 우리카지노사이트
    https://www.omgab.com/theking 더킹카지노
    https://www.omgab.com/sands 샌즈카지노
    https://www.omgab.com/first 퍼스트카지노
    https://www.omgab.com/yes 예스카지노
    https://www.omgab.com/super 슈퍼카지노
    https://www.omgab.com/gatsby 개츠비카지노
    https://www.omgab.com/33 33카지노
    https://www.omgab.com/world 월드카지노
    https://www.omgab.com/merit 메리트카지노

    ReplyDelete
  2. 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
  3. I am really happy with your blog because your article is very unique and powerful for new. . I want share about Aaraa couture

    ReplyDelete
  4. 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
  5. 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
  6. Nice piece of information. Kindly check out my new blog Monosnap Serial Key 2023

    ReplyDelete
  7. 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

Real Time Web Analytics