Since Json has only one type for Number, but C# has many types, like int, long, double, decimal, etc., when I use Utf8JsonReader, what is the correct way to retrieve number when after I call Read() and the TokenType is JsonTokenType.Number?
There are APIs such as GetInt32, GetInt64, GetDouble, GetDecimal, etc. and their TryGet... equivalents, but there is no clear indication of what C# type to use for given number value until one of these is actually called.
The only way I see right now is to call TryGet... APIs starting with the smallest I m interested in, e.g. TryGetInt32(), TryGetInt64(), TryGetFloat(), TryGetDouble(), until one of these succeeds. Even that is not clear since e.g. GetDouble() will succeed, even if the number of digits is too large for double, by rounding it. Is there any way to configure these APIs to succeed only if there is no loss of precision?
I guess I m just confused as to what is generally done when reading numbers with Utf8JsonReader.