ソースを参照

Serialize Guid.Empty to null

crobibero 4 年 前
コミット
c4925ad70b
1 ファイル変更10 行追加1 行削除
  1. 10 1
      MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs

+ 10 - 1
MediaBrowser.Common/Json/Converters/JsonGuidConverter.cs

@@ -15,6 +15,15 @@ namespace MediaBrowser.Common.Json.Converters
 
         /// <inheritdoc />
         public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options)
-            => writer.WriteStringValue(value);
+        {
+            if (value == Guid.Empty)
+            {
+                writer.WriteNullValue();
+            }
+            else
+            {
+                writer.WriteStringValue(value);
+            }
+        }
     }
 }