Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.31 KB

File metadata and controls

28 lines (21 loc) · 1.31 KB

StackExchange.Utils.Http.Extensions.System.Text.Json

Currently StackExchange.Utils.Http has dependency on Jil for Json serialization and deserialization.

This package allows to use System.Text.Json instead of JIL

StackExchange.Utils.Http.Extensions.System.Text.Json

How to use it

var result = await Http.Request("https://example.com")  
                       .SendSystemTextJson(new { name = "my thing" })
                       .ExpectSystemTextJson<MyType>(MyJsonSerializerSettings)
                       .GetAsync()

If serializerSettings is null, JsonSerializer will use default settings from DefaultSettings.

Of course, you can use all other features from StackExchange, like this:

var result = await Http.Request("https://example.com")
                       .IgnoredResponseStatuses(HttpStatusCode.NotFound)
                       .WithTimeout(TimeSpan.FromSeconds(20))
                       .SendSystemTextJson(new { name = "my thing" })
                       .ExpectSystemTextJson<MyType>()
                       .GetAsync();