Explorar el Código

Serialize Guid.Empty to null

crobibero hace 4 años
padre
commit
c4925ad70b
Se han modificado 1 ficheros con 10 adiciones y 1 borrados
  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);
+            }
+        }
     }
 }