public static PlayerChest ReadPlayerStash(string filePath) { string jsonData = File.ReadAllText(filePath); PlayerChest playerChest = JsonConvert.DeserializeObject <PlayerChest>(jsonData); return(playerChest); }
public static void WritePlayerChest(string outputPath, PlayerChest playerChest, bool backup = true) { if (backup) { if (File.Exists($"{outputPath}") && !File.Exists($"{outputPath}.bak")) { File.Copy(outputPath, outputPath + ".bak"); } } string newJsonFile = JsonConvert.SerializeObject(playerChest, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); File.WriteAllText(outputPath, newJsonFile); }