Class JsonNumber
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
asDouble()
Returns this JSON value as adouble
value, assuming that this value represents a JSON number.float
asFloat()
Returns this JSON value as afloat
value, assuming that this value represents a JSON number.int
asInt()
Returns this JSON value as anint
value, assuming that this value represents a JSON number that can be interpreted as Javaint
.long
asLong()
Returns this JSON value as along
value, assuming that this value represents a JSON number that can be interpreted as Javalong
.boolean
Indicates whether some other object is "equal to" this one according to the contract specified inObject.equals(Object)
.int
hashCode()
boolean
isNumber()
Detects whether this value represents a JSON number.toString()
Returns the JSON string for this value in its minimal form, without any additional whitespace.
-
Constructor Details
-
JsonNumber
Ctor.- Parameters:
string
- value
-
-
Method Details
-
toString
Description copied from class:JsonValue
Returns the JSON string for this value in its minimal form, without any additional whitespace. The result is guaranteed to be a valid input for the methodJson.parse(String)
and to create a value that is equal to this object. -
isNumber
public boolean isNumber()Description copied from class:JsonValue
Detects whether this value represents a JSON number. -
asInt
public int asInt()Description copied from class:JsonValue
Returns this JSON value as anint
value, assuming that this value represents a JSON number that can be interpreted as Javaint
. If this is not the case, an exception is thrown.To be interpreted as Java
int
, the JSON number must neither contain an exponent nor a fraction part. Moreover, the number must be in theInteger
range. -
asLong
public long asLong()Description copied from class:JsonValue
Returns this JSON value as along
value, assuming that this value represents a JSON number that can be interpreted as Javalong
. If this is not the case, an exception is thrown.To be interpreted as Java
long
, the JSON number must neither contain an exponent nor a fraction part. Moreover, the number must be in theLong
range. -
asFloat
public float asFloat()Description copied from class:JsonValue
Returns this JSON value as afloat
value, assuming that this value represents a JSON number. If this is not the case, an exception is thrown.If the JSON number is out of the
Float
range,Float.POSITIVE_INFINITY
orFloat.NEGATIVE_INFINITY
is returned. -
asDouble
public double asDouble()Description copied from class:JsonValue
Returns this JSON value as adouble
value, assuming that this value represents a JSON number. If this is not the case, an exception is thrown.If the JSON number is out of the
Double
range,Double.POSITIVE_INFINITY
orDouble.NEGATIVE_INFINITY
is returned. -
hashCode
public int hashCode() -
equals
Description copied from class:JsonValue
Indicates whether some other object is "equal to" this one according to the contract specified inObject.equals(Object)
.Two JsonValues are considered equal if and only if they represent the same JSON text. As a consequence, two given JsonObjects may be different even though they contain the same set of names with the same values, but in a different order.
-