Skip to content

Commit

Permalink
Improved SystemTextJson message accessor value retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Mar 29, 2024
1 parent b90a0a7 commit 3cdcf0d
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,7 @@ public CallResult<T> Deserialize<T>(MessagePath? path = null)
if (value.Value.ValueKind == JsonValueKind.Object || value.Value.ValueKind == JsonValueKind.Array)
return default;

var ttype = typeof(T);
if (ttype == typeof(string))
return (T?)(object?)value.Value.GetString();
if (ttype == typeof(short))
return (T)(object)value.Value.GetInt16();
if (ttype == typeof(int))
return (T)(object)value.Value.GetInt32();
if (ttype == typeof(long))
return (T)(object)value.Value.GetInt64();

return default;
return value.Value.Deserialize<T>();
}

/// <inheritdoc />
Expand Down

0 comments on commit 3cdcf0d

Please sign in to comment.