Property PreferDecimal
PreferDecimal
Declaration
public bool PreferDecimal { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
true to prefer using NumberValue over
DoubleValue to deserialize fractional numbers as
well as whole numbers outside of the range of long type,
false to prefer using DoubleValue. The
default is false .
|
Remarks
When deserializing JSON Number values, the whole numbers
are usually instantiated as IntegerValue or
LongValue. By default, fractional numbers are
instantiated as DoubleValue. In some cases, you may
prefer to use NumberValue instead, which stores
decimal
value. decimal
has bigger precision
(although smaller range) than double
. In addition,
double
store its value in binary format and thus may not
represent all decimal values precisely.
If PreferDecimal is set to true
, the
fractional numbers will be deserialized as
NumberValue, unless they are outside of the range of
Decimal in which case DoubleValue will
still be used.
In addition to fractional numbers, the above also applies to whole
numbers that are outside of the range of long
type.