@@ -28,7 +28,7 @@ private static string xml_to_json(string XML)
2828 var doc = new XmlDocument ( ) ;
2929 doc . LoadXml ( XML ) ;
3030 if ( doc . DocumentElement is null ) return "{'message': 'XmlDocument.DocumentElement was null'}" ;
31- return JsonSerializer . Serialize ( _convertXmlNode ( doc . DocumentElement ) , SerializingOptions ) ;
31+ return JsonSerializer . Serialize ( _convertXmlNode ( doc . DocumentElement ) , DefaultOptions ) ;
3232 }
3333
3434 private static object ? _convertXmlNode ( XmlNode node )
@@ -78,16 +78,32 @@ private static string xml_to_json(string XML)
7878 return dict ;
7979 }
8080
81- public static JsonSerializerOptions SerializingOptions = new ( )
81+ public static JsonSerializerOptions DefaultOptions = new ( )
8282 {
8383 TypeInfoResolver = new DefaultJsonTypeInfoResolver ( ) ,
84- NumberHandling = JsonNumberHandling . AllowNamedFloatingPointLiterals | JsonNumberHandling . AllowReadingFromString ,
8584 AllowTrailingCommas = true ,
8685 WriteIndented = true ,
87- Converters = { new FlexibleBooleanConverter ( ) , new FlexibleStringConverter ( ) , new FlexibleListStringConverter ( ) }
8886 } ;
8987
90- private class FlexibleBooleanConverter : JsonConverter < bool >
88+ public static JsonSerializerOptions ImportBundleOptions = new ( )
89+ {
90+ TypeInfoResolver = new DefaultJsonTypeInfoResolver ( ) ,
91+ NumberHandling =
92+ JsonNumberHandling . AllowNamedFloatingPointLiterals | JsonNumberHandling . AllowReadingFromString ,
93+ AllowTrailingCommas = true ,
94+ WriteIndented = true ,
95+ Converters =
96+ {
97+ new Converters . FlexibleBooleanConverter ( ) ,
98+ new Converters . FlexibleStringConverter ( ) ,
99+ new Converters . FlexibleListStringConverter ( )
100+ }
101+ } ;
102+ }
103+
104+ internal class Converters
105+ {
106+ public class FlexibleBooleanConverter : JsonConverter < bool >
91107 {
92108 public override bool Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
93109 {
@@ -110,7 +126,7 @@ public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOpti
110126 }
111127 }
112128
113- private class FlexibleStringConverter : JsonConverter < string >
129+ public class FlexibleStringConverter : JsonConverter < string >
114130 {
115131 public override string Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
116132 {
@@ -128,7 +144,7 @@ public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOp
128144 }
129145 }
130146
131- private class FlexibleListStringConverter : JsonConverter < List < string > >
147+ public class FlexibleListStringConverter : JsonConverter < List < string > >
132148 {
133149 public override List < string > Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
134150 {
0 commit comments