Successfully added
ASP.NET Core
by Patrik
Return JSON in camelCase
How to return JSON in camelCase?
Configure in Startup.cs
First of all, add this dependency:
using System.Text.Json;
Then add this in ConfigureServices():
services.AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; });
Change JsonSerializer options
Supply JsonSerializer.Serialize() with the optional JsonSerializerOptions object and override the casing:
string jsonString = JsonSerializer.Serialize(m, new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
Referenced in:
Comments