Class JsonNumber
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
A JSON number value that preserves the exact JSON token text so that no precision or formatting is lost.
public sealed class JsonNumber : JsonValue, IEquatable<JsonValue>
- Inheritance
-
JsonNumber
- Implements
- Inherited Members
Constructors
JsonNumber(string)
Initializes a new instance of the JsonNumber class from a raw JSON number token.
public JsonNumber(string rawToken)
Parameters
rawTokenstringThe exact JSON number token, for example
1.0or1e10.
Properties
Kind
Gets the kind of this value.
public override JsonValueKind Kind { get; }
Property Value
RawToken
Gets the exact JSON number token text.
public string RawToken { get; }
Property Value
Methods
Equals(JsonValue?)
Indicates whether the current object is equal to another object of the same type.
public override bool Equals(JsonValue? other)
Parameters
otherJsonValueAn object to compare with this object.
Returns
GetDecimal()
Gets the value as a decimal.
public decimal GetDecimal()
Returns
- decimal
The value.
Exceptions
- FormatException
Thrown if the token is not representable as a decimal.
GetDouble()
Gets the value as a double.
public double GetDouble()
Returns
- double
The value.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
GetInt64()
Gets the value as a long.
public long GetInt64()
Returns
- long
The value.
Exceptions
- FormatException
Thrown if the token is not an integer in range.
TryGetInt64(out long)
Attempts to get the value as a long.
public bool TryGetInt64(out long value)
Parameters
valuelongReceives the value.