tmenier / Flurl

Fluent URL builder and testable HTTP client for .NET
https://flurl.dev
MIT License
4.23k stars 387 forks source link

Remove non-generic dynamic-returning JSON methods #699

Closed tmenier closed 11 months ago

tmenier commented 2 years ago

4.0 will drop the the Newtonsoft.Json dependency and use System.Text.Json instead. But that library does not support deserializing to dynamic as Newtonsoft does, making it difficult at best to continue to support Flurl's non-generic dynamic-returning methods like GetJsonAsync(). The .NET team's rationale includes the fact that dynamic is now "archived" tech and therefore newer APIs shouldn't take a dependency on it.

So far the consensus seems to favor the outright removal of these methods from the core library, but feel free to weigh in here with your thoughts.

I intend to provide a NewtonsoftSerializer implementation compatible with 4.0 and onward for anyone who wants it. This will either be in the form of a separate NuGet package or just a gist (it's pretty tiny). Some of those pre-4.0 methods could be included, although doing it without them is as easy as:

// requires Newtonsoft-based serializer!
dynamic d = await requestOrUrl.GetJsonAsync<ExpandoObject>();