JsonValue(Double) Constructor

Initializes a new JsonValue struct that represents a number. An implicit conversion from the double type also exists. Some .NET numeric types such as long and decimal are not recommended to be encoded as JSON numbers. Use the ToJson extension methods if you still want to do so.


Namespace: KGySoft.Json
Assembly: KGySoft.Json (in KGySoft.Json.dll) Version: 3.0.0
public JsonValue(
	double value


value  Double
The value to initialize the JsonValue from.



  • JavaScript Number type is actually a double. Other large numeric types ([u]long/decimal) must be encoded as string to prevent loss of precision at a real JavaScript side. If you are sure that you want to forcibly treat such types as numbers use the ToJson overloads and pass to their asString parameter. You can use also the CreateNumberUnchecked method to create a JSON number directly from a string.
  • This method allows NaN and PositiveInfinity/NegativeInfinity, which are also invalid in JSON. Parsing these values works though their Type will be UnknownLiteral after parsing.

See Also