|
|
|
@ -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>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|