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 @@ + + + + + + + + + + + diff --git a/VL.CoreLib/src/Xml/Xml.cs b/VL.CoreLib/src/Xml/Xml.cs index 53409faf..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,18 @@ public enum ValidationType Schema } + /// + /// User-facing enum allowing to pick a naming policy for objects serialized with the ObjectToJson node + /// + public enum JsonPropertyNamingPolicy + { + CamelCase, + KebabCaseLower, + KebabCaseUpper, + SnakeCaseLower, + SnakeCaseUpper + } + public static class XmlNodes { /// @@ -331,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