class JsonNumber extends JsonValue
| Modifier and Type | Field and Description |
|---|---|
private String |
string |
TRANSFORM_LINE_LENGTH| Constructor and Description |
|---|
JsonNumber(String string) |
| Modifier and Type | Method and Description |
|---|---|
double |
asDouble()
Returns this JSON value as a
double value, assuming that this value represents a
JSON number. |
float |
asFloat()
Returns this JSON value as a
float value, assuming that this value represents a
JSON number. |
int |
asInt()
Returns this JSON value as an
int value, assuming that this value represents a
JSON number that can be interpreted as Java int. |
long |
asLong()
Returns this JSON value as a
long value, assuming that this value represents a
JSON number that can be interpreted as Java long. |
boolean |
equals(Object object)
Indicates whether some other object is "equal to" this one according to the contract specified
in
Object.equals(Object). |
int |
hashCode() |
boolean |
isNumber()
Detects whether this value represents a JSON number.
|
String |
toString()
Returns the JSON string for this value in its minimal form, without any additional whitespace.
|
(package private) void |
write(JsonWriter writer) |
private final String string
JsonNumber(String string)
public String toString()
JsonValue#readFrom(String) and to
create a value that is equal to this object.void write(JsonWriter writer) throws IOException
write in class JsonValueIOExceptionpublic boolean isNumber()
JsonValuepublic int asInt()
JsonValueint value, assuming that this value represents a
JSON number that can be interpreted as Java int. 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 the Integer range.
public long asLong()
JsonValuelong value, assuming that this value represents a
JSON number that can be interpreted as Java long. 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 the Long range.
public float asFloat()
JsonValuefloat 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 or
Float.NEGATIVE_INFINITY is returned.
public double asDouble()
JsonValuedouble 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 or
Double.NEGATIVE_INFINITY is returned.
public boolean equals(Object object)
JsonValueObject.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.
Copyright © 2011–2016 David R. Smith. All rights reserved.