-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONHelper.cs
More file actions
46 lines (43 loc) · 1.19 KB
/
JSONHelper.cs
File metadata and controls
46 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Strat_Assistant
{
public class LocalData
{
public bool CreateWizardOn { get; set; }
public bool Updated { get; set; }
}
public class JSONHelper
{
//Write vars to json file
public void JsonSerialize(LocalData localData)
{
try
{
File.WriteAllText(Global.localDataFilePath, JsonConvert.SerializeObject(localData, Formatting.Indented, new Newtonsoft.Json.Converters.StringEnumConverter()));
}
catch(Exception ex)
{
Global.LogError(ex);
}
}
//Read vars from Json file
public LocalData JsonDeserialize()
{
try
{
return JsonConvert.DeserializeObject<LocalData>(File.ReadAllText(Global.localDataFilePath), new Newtonsoft.Json.Converters.StringEnumConverter());
}
catch (Exception ex)
{
Global.LogError(ex);
return null;
}
}
}
}