Condensed code with use of ??
This commit is contained in:
+1
-6
@@ -35,13 +35,8 @@ public class BaseInteractionRequestDataConverter : JsonConverter<BaseInteraction
|
||||
var jsonText = jsonDocument.RootElement.GetRawText();
|
||||
|
||||
// Get the underlying 'type' of action the client is requesting we do
|
||||
var action = jsonDocument.RootElement.GetProperty("Action").GetString();
|
||||
|
||||
// Handle nullability here in case action's GetString is null
|
||||
if (action is null)
|
||||
{
|
||||
action = string.Empty;
|
||||
}
|
||||
var action = jsonDocument.RootElement.GetProperty("Action").GetString() ?? string.Empty;
|
||||
|
||||
return ConvertToCorrectType(action, jsonDocument.RootElement, jsonText, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user