Skip to content

Use NewtonSoft Json.net instead of JIL in StackExchange.Utils.Http

License

Notifications You must be signed in to change notification settings

TraceParts/StackExchange.Utils.Http.Extensions.NewtonJson

Repository files navigation

StackExchange.Utils.Http.Extensions.NewtonJson

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

This package allows to use NewtonSoft Json.NET instead of JIL

StackExchange.Utils.Http.Extensions.NewtonJson

How to use it

var result = await Http.Request("https://example.com")  
                       .SendNewtonJson(new { name = "my thing" })
                       .ExpectNewtonJson<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))
                       .SendNewtonJson(new { name = "my thing" })
                       .ExpectNewtonJson<MyType>()
                       .GetAsync();

About

Use NewtonSoft Json.net instead of JIL in StackExchange.Utils.Http

Topics

Resources

License

Stars

Watchers

Forks

Languages