Skip to content

Commit

Permalink
check token type and use ToString()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaspimentel committed Jun 18, 2024
1 parent f2fcc64 commit d0b7e98
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,17 @@ bool ITelemeteredConfigurationSource.IsPresent(string key)

try
{
var valueAsString = token?.Value<string>();
var valueAsString = token switch
{
null => null,
_ => token.Type switch
{
JTokenType.Null or JTokenType.None or JTokenType.Undefined => null,
JTokenType.String => token.Value<string>(),
_ => token.ToString()
}
};

if (valueAsString is not null)
{
var value = converter(valueAsString);
Expand Down

0 comments on commit d0b7e98

Please sign in to comment.