mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 15:23:50 +02:00
Handle parsing malformed user created VRC config.json files
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace VRCX
|
||||
{
|
||||
@@ -18,6 +19,27 @@ namespace VRCX
|
||||
return json;
|
||||
}
|
||||
|
||||
public string ReadConfigFileSafe()
|
||||
{
|
||||
try
|
||||
{
|
||||
var configFile = ReadConfigFile();
|
||||
if (string.IsNullOrEmpty(configFile))
|
||||
return string.Empty;
|
||||
|
||||
var jObject = JsonConvert.DeserializeObject<dynamic>(configFile, JsonSerializerSettings);
|
||||
if (jObject == null)
|
||||
return string.Empty;
|
||||
|
||||
return JsonConvert.SerializeObject(jObject, Formatting.Indented);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Warn(ex, "Failed to parse VRC config.json file");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteConfigFile(string json)
|
||||
{
|
||||
var path = GetVRChatAppDataLocation();
|
||||
|
||||
Reference in New Issue
Block a user