JorgeSerrano.Json.JsonSnakeCaseNamingPolicy 0.9.0

Install-Package JorgeSerrano.Json.JsonSnakeCaseNamingPolicy -Version 0.9.0
dotnet add package JorgeSerrano.Json.JsonSnakeCaseNamingPolicy --version 0.9.0
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

  • .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 2,526 4/9/2021