summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Toolkit/Serialization/JsonHelper.cs')
-rw-r--r--src/SMAPI.Toolkit/Serialization/JsonHelper.cs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
index 3c9308f2..1a003c51 100644
--- a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
+++ b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs
@@ -108,12 +108,11 @@ namespace StardewModdingAPI.Toolkit.Serialization
/// <summary>Deserialize JSON text if possible.</summary>
/// <typeparam name="TModel">The model type.</typeparam>
/// <param name="json">The raw JSON text.</param>
- public TModel Deserialize<TModel>(string json)
+ public TModel? Deserialize<TModel>(string json)
{
try
{
- return JsonConvert.DeserializeObject<TModel>(json, this.JsonSettings)
- ?? throw new InvalidOperationException($"Couldn't deserialize model type '{typeof(TModel)}' from empty or null JSON.");
+ return JsonConvert.DeserializeObject<TModel>(json, this.JsonSettings);
}
catch (JsonReaderException)
{