@pianoboy11 , you could use JsonSerializerSettings to give the default value.
Like the following code:
static void Main(string[] args)
{
var options = new JsonSerializerOptions
{
NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.AllowNamedFloatingPointLiterals
};
Test test = new Test();
test.Name = "test1";
test.Amount = double.NaN;
Console.WriteLine(JsonSerializer.Serialize(test,options));
}
public class Test
{
public string Name { get; set; }
public double Amount { get; set; }
}
Result:
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.