Flurl icon indicating copy to clipboard operation
Flurl copied to clipboard

Remove non-generic dynamic-returning JSON methods

Open tmenier opened this issue 2 years ago • 0 comments

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>();

tmenier avatar Jun 03 '22 14:06 tmenier