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. Thank you so much for providing good quality information. 먹튀검증업체 I think it would not have been easy to collect this information and organize it in an easy to understand way. I'll add it to my bookmarks so I can visit it often! And I will share it with my acquaintances. And there is a lot of useful information on our website too, so please take a look and take a look. Then have a good day. 안전토토사이트

    ReplyDelete
  2. 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
  3. When I read your article on this topic, the first thought seems profound and difficult. There is also a bulletin board for discussion of articles and photos similar to this topic on my site, but I would like to visit once when I have time to discuss this topic. 메이저사이트

    ReplyDelete
  4. I’m thinking some of my readers might find a bit of this interesting. Do you mind if I post a clip from this and link back? Thanks 사설토토

    ReplyDelete
  5. 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
  6. Sonic Mania is a throwback to the original quadrilogy of Sonic games on the Sega Genesis, but it far outperforms them in terms of quality and fun. The game feels like it picks up where Sonic and Knuckles left off in terms of gameplay quality.
    sonic mania pc crack

    ReplyDelete

Real Time Web Analytics