Is there a way to designate that the Type of a JToken
is of type double
or long
? I noticed that only integer
s and float
s are supported via https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Linq/JTokenType.cs and wonder how people handle the higher precision cases.
JSON doesn't distinguish between double
and float
. It doesn't even really distinguish between integers and non-integers - they're just numbers.
But JsonTokenType.Float
isn't really meant to indicate System.Single
- it's "a floating point number". Likewise JsonTokenType.Integer
isn't meant to indicate System.Int32
- it's "an integer".
For examples of this, look at JValue
:
long
sets the token type to Integer
double
sets the token type to Float
decimal
sets the token type to Float
See more on this question at Stackoverflow