JsonNamingPolicy
Naming policies for System.Text.Json
Install / Use
/learn @J0rgeSerran0/JsonNamingPolicyREADME
JsonNamingPolicy
Naming policies for System.Text.Json
This GitHub repo contains classes to change the name properties of a JSON into different naming conventions.
Update April 5 2022
Unlikely it will be added in .NET 7

Update Jul 23 2021
Microsoft has moved the implementation of kebab-case and snake_case to .NET 7
Additional information here
NuGet Package
Update Oct 13 2021 - NuGet Package NickJohn published 6 months ago, a NuGet Package with the code I share here.
You can incorporate the code easily inside of your developments.
You will find this NuGet Package here
Thanks a lot NickeJohn
JsonSnakeCaseNamingPolicy
This class creates a policy to change the name properties of a JSON into SnakeCase (snake_case) used in some programming languages and APIs.
This code passes the tests that you will find in the corefx SnakeCaseUnitTests of Microsoft
Use
var options = new JsonSerializerOptions() { PropertyNamingPolicy = new JsonSnakeCaseNamingPolicy() };
var person = new Person() { FirstName = "Jorge", Birthday = DateTime.UtcNow, MyJobCity = "Madrid" };
var json = JsonSerializer.Serialize(person, options);
Result
{"first_name":"Jorge","birthday":"2020-01-03T20:00:59.6991482Z","my_job_city":"Madrid"}
JsonKebabCaseNamingPolicy
This class creates a policy to change the name properties of a JSON into KebabCase (kebab-case).
Use
var options = new JsonSerializerOptions() { PropertyNamingPolicy = new JsonKebabCaseNamingPolicy() };
var person = new Person() { FirstName = "Jorge", Birthday = DateTime.UtcNow, MyJobCity = "Madrid" };
var json = JsonSerializer.Serialize(person, options);
Result
{"first-name":"Jorge","birthday":"2020-01-03T20:00:59.6991482Z","my-job-city":"Madrid"}
Related Skills
node-connect
335.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.5kCommit, push, and open a PR

