From 19b84f093eb372529d05ea99ad807234a848646d Mon Sep 17 00:00:00 2001 From: sebescudie Date: Fri, 18 Jul 2025 13:22:11 +0200 Subject: [PATCH 1/3] Introduces JsonPropertyNamingPolicy enum Will allow to quickly set a naming policy from an enum rather than having to place nodes returning the naming policy --- VL.CoreLib/src/Xml/Xml.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/VL.CoreLib/src/Xml/Xml.cs b/VL.CoreLib/src/Xml/Xml.cs index 53409faf..ce81d781 100644 --- a/VL.CoreLib/src/Xml/Xml.cs +++ b/VL.CoreLib/src/Xml/Xml.cs @@ -24,6 +24,15 @@ public enum ValidationType Schema } + public enum JsonPropertyNamingPolicy + { + CamelCase, + KebabCaseLower, + KebabCaseUpper, + SnakeCaseLower, + SnakeCaseUpper + } + public static class XmlNodes { /// From 0bdf3567dcb9ca564ac55927a939b083a5e1db9e Mon Sep 17 00:00:00 2001 From: sebescudie Date: Fri, 18 Jul 2025 13:43:12 +0200 Subject: [PATCH 2/3] Adds summaries, introduces GetJsonNamingPolicyFromEnum allowing to get an actual JsonNamingPolicy from a JsonPropertyNamingPolicy enum value --- VL.CoreLib/src/Xml/Xml.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/VL.CoreLib/src/Xml/Xml.cs b/VL.CoreLib/src/Xml/Xml.cs index ce81d781..845e01ca 100644 --- a/VL.CoreLib/src/Xml/Xml.cs +++ b/VL.CoreLib/src/Xml/Xml.cs @@ -14,6 +14,7 @@ using VL.Core; using VL.Lib.Basics.Resources; using VL.Lib.Collections; +using System.Text.Json; namespace VL.Lib.Xml { @@ -24,6 +25,9 @@ public enum ValidationType Schema } + /// + /// User-facing enum allowing to pick a naming policy for objects serialized with the ObjectToJson node + /// public enum JsonPropertyNamingPolicy { CamelCase, @@ -340,5 +344,24 @@ static public string TransformXDocument(XDocument input, string xsl) return writer.ToString(); } } + + /// + /// Returns a JsonNamingPolicy from a JsonPropertyNamingPolicy + /// + /// + /// + /// + public static JsonNamingPolicy GetJsonNamingPolicyFromEnum(JsonPropertyNamingPolicy input) + { + return input switch + { + JsonPropertyNamingPolicy.CamelCase => JsonNamingPolicy.CamelCase, + JsonPropertyNamingPolicy.KebabCaseLower => JsonNamingPolicy.KebabCaseLower, + JsonPropertyNamingPolicy.KebabCaseUpper => JsonNamingPolicy.KebabCaseUpper, + JsonPropertyNamingPolicy.SnakeCaseLower => JsonNamingPolicy.SnakeCaseLower, + JsonPropertyNamingPolicy.SnakeCaseUpper => JsonNamingPolicy.SnakeCaseUpper, + _ => throw new ArgumentOutOfRangeException("input", input, "Could not create JsonNamingPolicy with provided value") + }; + } } } \ No newline at end of file From bb8e1f77746a24e36e7dcaff697e98d21ceb3963 Mon Sep 17 00:00:00 2001 From: sebescudie Date: Fri, 18 Jul 2025 13:51:04 +0200 Subject: [PATCH 3/3] Introduces Property Naming Policy input pin on ObjectToJson Internally uses enum and function from previous commits --- VL.CoreLib/VL.Xml.vl | 82 +++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/VL.CoreLib/VL.Xml.vl b/VL.CoreLib/VL.Xml.vl index 9cd8ba2e..0cb339bf 100644 --- a/VL.CoreLib/VL.Xml.vl +++ b/VL.CoreLib/VL.Xml.vl @@ -1,5 +1,5 @@  - + @@ -55,11 +55,9 @@ - - @@ -165,11 +163,9 @@ - - @@ -282,10 +278,8 @@ - - @@ -405,10 +399,8 @@ - - @@ -6236,7 +6228,7 @@ - + @@ -6254,7 +6246,7 @@ - + @@ -6276,7 +6268,7 @@ - + @@ -6332,7 +6324,7 @@ - + @@ -6351,7 +6343,7 @@ - + @@ -6371,7 +6363,7 @@ - + @@ -6381,7 +6373,7 @@ - + @@ -6391,7 +6383,7 @@ - + @@ -6443,12 +6435,12 @@ ************************ ObjectToJson ************************ --> - + - + @@ -6457,8 +6449,8 @@ - - + + @@ -6466,7 +6458,7 @@ - + @@ -6476,7 +6468,7 @@ - + @@ -6491,25 +6483,42 @@ + + + + + + + + + + + + + + + + + + - - - - + + + + - + - - + - + @@ -6526,6 +6535,17 @@ + + + + + + + + + + +