JsonNumber Class
- java.
lang. Object - com.
azure. json. models. JsonElement - com.
azure. json. models. JsonNumber
- com.
- com.
public final class JsonNumber
extends JsonElement
Class representing the JSON number type
Constructor Summary
| Constructor | Description |
|---|---|
| JsonNumber(Number value) |
Creates a Json |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Json |
fromJson(JsonReader jsonReader)
Deserializes a JSON number from a Json |
| Number |
getValue()
Returns the Number value from a Json |
| boolean |
isNumber()
Whether the Json |
|
Json |
toJson(JsonWriter jsonWriter) |
| String | toJsonString() |
Methods inherited from JsonElement
Methods inherited from java.lang.Object
Constructor Details
JsonNumber
public JsonNumber(Number value)
Creates a JsonNumber representing the specified number.
Parameters:
Method Details
fromJson
public static JsonNumber fromJson(JsonReader jsonReader)
Deserializes a JSON number from a JsonReader.
If the JsonReader's current token is null, it is assumed the JsonReader hasn't begun reading and nextToken() will be called to begin reading.
After ensuring the JsonReader has begun reading, if the current token is not NUMBER, an IllegalStateException will be thrown. Otherwise, a JSON number representing the numeric value will be created and returned.
For integer numbers, this method will return the smallest number type that can represent the number. Where Integer is preferred over Long and Long is preferred over BigInteger.
For floating point numbers, Double will be preferred but BigDecimal will be used if the number is too large to fit in a Double.
If the string is one of the special floating point representations (NaN, Infinity, etc), then the value will be represented using Double.
Parameters:
Returns:
Throws:
getValue
public Number getValue()
Returns the Number value from a JsonNumber object.
The value returned by this method will never be null.
Returns:
isNumber
public boolean isNumber()
Whether the JsonElement is a JsonNumber.
Overrides:
JsonNumber.isNumber()Returns: