.net core : incomplete JSON response

后端 未结 6 1866
萌比男神i
萌比男神i 2020-12-18 21:08

I\'m trying to build simple API for training, in my database I got users (firstname, lastname, email password, list) and sports ( name, userID). A

6条回答
  •  旧巷少年郎
    2020-12-18 21:35

    In my case this solve my issue on core 3, by using Newtonsoft: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-3.0#add-newtonsoftjson-based-json-format-support

    Prior to ASP.NET Core 3.0, the default used JSON formatters implemented using the Newtonsoft.Json package. In ASP.NET Core 3.0 or later, the default JSON formatters are based on System.Text.Json. Support for Newtonsoft.Json based formatters and features is available by installing the Microsoft.AspNetCore.Mvc.NewtonsoftJson NuGet package and configuring it in Startup.ConfigureServices.

        public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers()
            .AddNewtonsoftJson();
    }
    

提交回复
热议问题