JsonSrcGen icon indicating copy to clipboard operation
JsonSrcGen copied to clipboard

How can JsonSrcGen be configured in ASP.NET Core applications?

Open fbridger opened this issue 3 years ago • 1 comments

Is there any way to use the serializer/deserializer that JsonSrcGen produces as the default Json serializer/deserializer in ASP.NET Core applications?

fbridger avatar Jun 11 '21 12:06 fbridger

I haven't built anything to do this, but it is definitely something I would like to look into.

One issue that we might run into is that JsonSrcGen doesn't require a lookup to determine the serializer to use for a type, this is because it exposes a separate method for each type which are called directly. This is big performance win. However this advantage will get lost when used as the default serializer because the methods cannot be called directly and so we will have to make a lookup from the type to the method

Even with this lookup JsonSrcGen will likely still be very competitive, but it is worth noting this potential issue.

trampster avatar Jun 13 '21 10:06 trampster