Browse Source

Fix nullable defaults for GetPropertyValueOrDefault

pull/333/head
Ionite 1 year ago
parent
commit
34d46e706f
No known key found for this signature in database
  1. 6
      StabilityMatrix.Core/Extensions/JsonObjectExtensions.cs

6
StabilityMatrix.Core/Extensions/JsonObjectExtensions.cs

@ -8,10 +8,10 @@ public static class JsonObjectExtensions
/// <summary>
/// Returns the value of a property with the specified name, or the specified default value if not found.
/// </summary>
public static T GetPropertyValueOrDefault<T>(
public static T? GetPropertyValueOrDefault<T>(
this JsonObject jsonObject,
string propertyName,
T defaultValue
T? defaultValue = default
)
{
if (!jsonObject.TryGetPropertyValue(propertyName, out var node))
@ -19,6 +19,6 @@ public static class JsonObjectExtensions
return defaultValue;
}
return node.Deserialize<T>() ?? defaultValue;
return node.Deserialize<T>();
}
}

Loading…
Cancel
Save