From 0b106fd9de4b69fe512df71610c9b92e8836b69a Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 14 Jun 2022 16:46:25 +0200 Subject: [PATCH 1/2] Update README.md Thought it will be good idea to include `JsonLowerCaseNamingPolicy` in example, started to look for it in google and then realized it's a custom policy. Maybe also good to include this naming policy in source code so folks don't need to create it? Let me know, happy to do it. --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8c2177..2874173 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,16 @@ jsonSerializerOptions.PropertyNamingPolicy = new JsonLowerCaseNamingPolicy(); jsonSerializerOptions.AddProtobufSupport(); ``` +```csharp +private class JsonLowerCaseNamingPolicy : JsonNamingPolicy +{ + public override string ConvertName(string name) + { + return name.ToLower(); + } +} +``` + You need to pass the options each time you want to serialize: ```csharp @@ -73,4 +83,4 @@ Apple M1 Pro, 1 CPU, 10 logical and 10 physical cores ## License -This project uses [MIT licence](https://github.com/Havret/Protobuf.System.Text.Json/blob/main/LICENSE). Long story short - you are more than welcome to use it anywhere you like, completely free of charge and without oppressive obligations. \ No newline at end of file +This project uses [MIT licence](https://github.com/Havret/Protobuf.System.Text.Json/blob/main/LICENSE). Long story short - you are more than welcome to use it anywhere you like, completely free of charge and without oppressive obligations. From f87c21e8e5ee8db77381f76c5b086bc9186d1f25 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 14 Jun 2022 22:22:28 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index 2874173..b127348 100644 --- a/README.md +++ b/README.md @@ -21,20 +21,10 @@ To enable Protobuf support you need to register it on `JsonSerializerOptions`: ```csharp var jsonSerializerOptions = new JsonSerializerOptions(); -jsonSerializerOptions.PropertyNamingPolicy = new JsonLowerCaseNamingPolicy(); +jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; jsonSerializerOptions.AddProtobufSupport(); ``` -```csharp -private class JsonLowerCaseNamingPolicy : JsonNamingPolicy -{ - public override string ConvertName(string name) - { - return name.ToLower(); - } -} -``` - You need to pass the options each time you want to serialize: ```csharp