-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathUtil.cs
30 lines (28 loc) · 895 Bytes
/
Util.cs
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
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 WVCore.Server
{
internal class Util
{
public static string ConvertToJson(object o)
{
var options = new JsonSerializerOptions
{
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = false,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Converters = { new JsonStringEnumConverter() }
};
return JsonSerializer.Serialize(o, options);
}
public static string BytesToHex(byte[] data, string split = "")
{
return BitConverter.ToString(data).Replace("-", split);
}
}
}