pull/1172/head
2dust 4 years ago
parent e7231d33b3
commit 378f350c52

@ -84,7 +84,7 @@ namespace v2rayN.Handler
// TODO: 统计配置
statistic(config, ref v2rayConfig);
Utils.ToJsonFile(v2rayConfig, fileName);
Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), config.getSummary());
}
@ -919,7 +919,7 @@ namespace v2rayN.Handler
//传出设置
ServerOutbound(config, ref v2rayConfig);
Utils.ToJsonFile(v2rayConfig, fileName);
Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), config.getSummary());
}

@ -119,16 +119,22 @@ namespace v2rayN
/// <param name="obj"></param>
/// <param name="filePath"></param>
/// <returns></returns>
public static int ToJsonFile(Object obj, string filePath)
public static int ToJsonFile(Object obj, string filePath, bool nullValue = true)
{
int result;
try
{
using (StreamWriter file = File.CreateText(filePath))
{
//JsonSerializer serializer = new JsonSerializer();
JsonSerializer serializer = new JsonSerializer() { Formatting = Formatting.Indented };
//JsonSerializer serializer = new JsonSerializer() { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore };
JsonSerializer serializer;
if (nullValue)
{
serializer = new JsonSerializer() { Formatting = Formatting.Indented };
}
else
{
serializer = new JsonSerializer() { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore };
}
serializer.Serialize(file, obj);
}
@ -800,7 +806,7 @@ namespace v2rayN
public static string GetTempPath(string filename)
{
return Path.Combine(GetTempPath(), filename);
}
}
public static string UnGzip(byte[] buf)
{

Loading…
Cancel
Save