0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 09:50:43 -05:00

Add Method to use singleQuotes in serializer, remove workaround

This commit is contained in:
CWX 2024-12-26 22:30:20 +00:00
parent c7641677ae
commit bc2714ceee
2 changed files with 18 additions and 1 deletions

View File

@ -124,7 +124,7 @@ namespace SPT.Launcher
//start game
var args =
$"-force-gfx-jobs native -token={account.id} -config={{'BackendUrl':'{server.backendUrl}','Version':'live','MatchingVersion':'live'}}"; // Old Way: {Json.Serialize(new ClientConfig(server.backendUrl))} - Workaround for now
$"-force-gfx-jobs native -token={account.id} -config={Json.SerializeSingleQuotes(new ClientConfig(server.backendUrl))}";
if (_showOnly)
{

View File

@ -12,6 +12,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Linq;
using System.Text;
using SPT.Launcher.Controllers;
namespace SPT.Launcher.MiniCommon
@ -23,6 +24,22 @@ namespace SPT.Launcher.MiniCommon
return JsonConvert.SerializeObject(data);
}
public static string SerializeSingleQuotes<T>(T Data)
{
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
using (JsonTextWriter jw = new JsonTextWriter(sw))
{
jw.QuoteChar = '\'';
JsonSerializer ser = new JsonSerializer();
ser.Serialize(jw, Data);
}
return sb.ToString();
}
public static T Deserialize<T>(string json)
{
return JsonConvert.DeserializeObject<T>(json);