This commit is contained in:
Archi
2024-02-27 01:44:21 +01:00
parent 5135677360
commit 86bfc73187

View File

@@ -34,7 +34,13 @@ internal sealed class GuidJsonConverter : JsonConverter<Guid> {
internal static readonly GuidJsonConverter Shared = new();
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) {
if (reader.TryGetGuid(out Guid result)) {
// Great, we can work with it
return result;
}
try {
// Try again using more flexible implementation, sigh
return Guid.Parse(reader.GetString()!);
} catch {
// Throw JsonException instead, which will be converted into standard message by STJ