-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJSON.cs
More file actions
38 lines (34 loc) · 1003 Bytes
/
JSON.cs
File metadata and controls
38 lines (34 loc) · 1003 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace LocalProgression
{
internal static class JSON
{
private static JsonSerializerOptions _setting;
public static T Deserialize<T>(string json)
{
return JsonSerializer.Deserialize<T>(json, _setting);
}
public static string Serialize<T>(T value)
{
return JsonSerializer.Serialize(value, _setting);
}
static JSON()
{
_setting = new()
{
ReadCommentHandling = JsonCommentHandling.Skip,
IncludeFields = false,
PropertyNameCaseInsensitive = true,
WriteIndented = true,
IgnoreReadOnlyProperties = true
};
_setting.Converters.Add(new JsonStringEnumConverter());
}
}
}