JorgeSerrano.Json.JsonSnakeCaseNamingPolicy 0.9.0

.NET Core 3.1
dotnet add package JorgeSerrano.Json.JsonSnakeCaseNamingPolicy --version 0.9.0
NuGet\Install-Package JorgeSerrano.Json.JsonSnakeCaseNamingPolicy -Version 0.9.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JorgeSerrano.Json.JsonSnakeCaseNamingPolicy" Version="0.9.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JorgeSerrano.Json.JsonSnakeCaseNamingPolicy --version 0.9.0
#r "nuget: JorgeSerrano.Json.JsonSnakeCaseNamingPolicy, 0.9.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install JorgeSerrano.Json.JsonSnakeCaseNamingPolicy as a Cake Addin
#addin nuget:?package=JorgeSerrano.Json.JsonSnakeCaseNamingPolicy&version=0.9.0

// Install JorgeSerrano.Json.JsonSnakeCaseNamingPolicy as a Cake Tool
#tool nuget:?package=JorgeSerrano.Json.JsonSnakeCaseNamingPolicy&version=0.9.0

Namespace JSON Naming Policies Compatibility

JsonNamingPolicy

Naming policies for System.Text.Json

This GitHub repo contains classes to change the name properties of a JSON into different naming conventions.

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

using JorgeSerrano.Json;
...
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

using JorgeSerrano.Json;
...
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"}

Disclaimer

This library is written by J0rgeSerran0 on GitHub, not by me. I packaged and published it to NuGet just for convenience.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.9.0 37,593 4/9/2021