From 61fb402a300eab924a14a43f1844c8c1a4de2fa5 Mon Sep 17 00:00:00 2001 From: doombubbles Date: Thu, 2 Nov 2023 12:15:03 -0700 Subject: [PATCH] Make static JsonSerializerSettings --- BloonsTD6 Mod Helper/Api/Helpers/FileIOHelper.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BloonsTD6 Mod Helper/Api/Helpers/FileIOHelper.cs b/BloonsTD6 Mod Helper/Api/Helpers/FileIOHelper.cs index 5d15eee2f..fba1e0521 100644 --- a/BloonsTD6 Mod Helper/Api/Helpers/FileIOHelper.cs +++ b/BloonsTD6 Mod Helper/Api/Helpers/FileIOHelper.cs @@ -13,6 +13,13 @@ namespace BTD_Mod_Helper.Api.Helpers; /// public static class FileIOHelper { + internal static readonly JsonSerializerSettings Settings = new() + { + Formatting = Formatting.Indented, + TypeNameHandling = TypeNameHandling.Objects, + _referenceLoopHandling = new Nullable {value = ReferenceLoopHandling.Ignore} + }; + /// /// Same as the original FileIOUtil.sandboxRoot, INCLUDES A SLASH AT THE END /// @@ -32,12 +39,7 @@ public static class FileIOHelper /// public static void SaveObject(string fileName, Object data) { - var text = JsonConvert.SerializeObject(data, new JsonSerializerSettings - { - Formatting = Formatting.Indented, - TypeNameHandling = TypeNameHandling.Objects, - _referenceLoopHandling = new Nullable {value = ReferenceLoopHandling.Ignore} - }); + var text = JsonConvert.SerializeObject(data, Settings); SaveFile(fileName, text); }