Revisión | 6f64ad589c15cfa359271bf14a41ead39f6b8359 (tree) |
---|---|
Tiempo | 2022-08-06 01:31:36 |
Autor | yoshy <yoshy.org.bitbucket@gz.j...> |
Commiter | yoshy |
[MOD] JSON シリアライザを System.Runtime.Serialization.Json から System.Text.Json の実装に変更
@@ -1,9 +1,8 @@ | ||
1 | -using System.IO; | |
2 | -using System.Runtime.Serialization.Json; | |
3 | -using System.Text; | |
1 | +using System.Text.Json; | |
4 | 2 | |
5 | 3 | namespace CleanAuLait.Core.Converter |
6 | 4 | { |
5 | +#if false | |
7 | 6 | /// <see href="https://mokake.hatenablog.com/entry/2017/09/12/195656"> |
8 | 7 | public static class JsonHelper |
9 | 8 | { |
@@ -22,4 +21,18 @@ namespace CleanAuLait.Core.Converter | ||
22 | 21 | return (T)serializer.ReadObject(stream); |
23 | 22 | } |
24 | 23 | } |
24 | +#else | |
25 | + public static class JsonHelper | |
26 | + { | |
27 | + public static string ToJsonString<T>(this T data) | |
28 | + { | |
29 | + return JsonSerializer.Serialize(data); | |
30 | + } | |
31 | + | |
32 | + public static T DeserializeJson<T>(this string json) | |
33 | + { | |
34 | + return JsonSerializer.Deserialize<T>(json); | |
35 | + } | |
36 | + } | |
37 | +#endif | |
25 | 38 | } |