Last post Jul 23, 2020 11:25 AM by 9peculiar
Jul 19, 2020 01:55 PM|9peculiar|LINK
I installed Newtonsoft.Json in my ASP.NET Core in my web development project. Although my models names start with Uppercase letter, the Json string return them lowercase so I can't render them in the jqgrid. I guess that I have to instruct the application
in the start class to override this behavior but I'm exhausting searching for how to do it.
Start up class
public void ConfigureServices(IServiceCollection services)
services.AddMvc().AddNewtonsoftJson(options => options.SerializerSettings ????????
Jul 19, 2020 02:19 PM|mgebhard|LINK
The solution depends on the version of Core and project type. The standard ASP.NET docs cover JSON format fundamentals.
Jul 20, 2020 06:39 AM|Rena Ni|LINK
For asp.net core 3.x,it should be like below:
services.AddControllers() .AddNewtonsoftJson(opt => opt.SerializerSettings.ContractResolver = new DefaultContractResolver());
For asp.net core 2.x,it should be like below:
services.AddMvc() .AddJsonOptions(opt =>
opt.SerializerSettings.ContractResolver = new DefaultContractResolver());
Jul 20, 2020 03:40 PM|bruce (sqlwork.com)|LINK
jqGrid does not care the case of the columns, though most examples would be lowercase. By convention json data is camelcased, which is why asp.net core switched to this as a default.
I would suggest just fixing the jqGrid config and following the conventions.
Jul 23, 2020 11:25 AM|9peculiar|LINK
Thanks Rena Ni....I followed your advice and works