22
33using References ::Newtonsoft . Json ;
44using System ;
5+ using System . Globalization ;
56using System . IO ;
67
78namespace Oxide . Core . Configuration
@@ -11,6 +12,13 @@ namespace Oxide.Core.Configuration
1112 /// </summary>
1213 public abstract class ConfigFile
1314 {
15+ private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings ( )
16+ {
17+ DefaultValueHandling = DefaultValueHandling . Populate , Culture = CultureInfo . InvariantCulture ,
18+ Formatting = Formatting . Indented ,
19+ MissingMemberHandling = MissingMemberHandling . Ignore
20+ } ;
21+
1422 [ JsonIgnore ]
1523 public string Filename { get ; private set ; }
1624
@@ -37,7 +45,7 @@ public static T Load<T>(string filename) where T : ConfigFile
3745 public virtual void Load ( string filename = null )
3846 {
3947 string source = File . ReadAllText ( filename ?? Filename ) ;
40- JsonConvert . PopulateObject ( source , this ) ;
48+ JsonConvert . PopulateObject ( source , this , SerializerSettings ) ;
4149 }
4250
4351 /// <summary>
@@ -46,7 +54,7 @@ public virtual void Load(string filename = null)
4654 /// <param name="filename"></param>
4755 public virtual void Save ( string filename = null )
4856 {
49- string source = JsonConvert . SerializeObject ( this , Formatting . Indented ) ;
57+ string source = JsonConvert . SerializeObject ( this , SerializerSettings ) ;
5058 File . WriteAllText ( filename ?? Filename , source ) ;
5159 }
5260 }
0 commit comments