Saturday, August 31, 2024

[ASP.NET Core] HTTP response JSON format

 ASP.NET Core    Newtonsoft.Json    System.Text.Json 


▌Configuration


The following codes in Startup.cs: ConfigureServices(IServiceCollection services) , show the difference of JSON serialization for HTTP response with Newtonsoft.Json and System.Text.Json.

▋System.Text.Json

The namespace had been included in runtime in .NET Core 3.1 and later versions.


▋Newtonsoft.Json

If we still want to use Newtonsoft.Json as the default serialization/deserialization package, install it and write as following. 



No comments:

Post a Comment