java.lang.Object | |
↳ | com.urbanairship.json.JsonValue |
A JsonValue is a representation of any value that can be described using JSON. It can contain one of the following: a JsonMap, a JsonList, a Number, a Boolean, String, or it can contain null.
JsonValues can be created from Java Objects by calling wrap(Object)
or from a JSON
String by callingparseString(String)
. The JsonValue toString()
returns the
JSON String representation of the object.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final JsonValue | NULL | A null representation of the JsonValue. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String |
coerceString()
Gets the contained value coerced into a String.
| ||||||||||
int | describeContents() | ||||||||||
boolean | equals(Object object) | ||||||||||
boolean |
getBoolean(boolean defaultValue)
Gets the contained values as a boolean.
| ||||||||||
Boolean |
getBoolean()
Gets the contained values as a boolean.
| ||||||||||
double |
getDouble(double defaultValue)
Gets the contained values as an double.
| ||||||||||
float |
getFloat(float defaultValue)
Gets the contained values as a float.
| ||||||||||
int |
getInt(int defaultValue)
Gets the contained values as an int.
| ||||||||||
Integer |
getInteger()
Gets the contained values as an Integer.
| ||||||||||
JsonList |
getList()
Gets the contained value as a JsonList.
| ||||||||||
long |
getLong(long defaultValue)
Gets the contained values as an long.
| ||||||||||
JsonMap |
getMap()
Gets the contained values as a JsonMap.
| ||||||||||
Number |
getNumber()
Gets the contained values as a Number.
| ||||||||||
String |
getString()
Gets the contained value as a String.
| ||||||||||
String |
getString(String defaultValue)
Gets the contained values as a String.
| ||||||||||
Object |
getValue()
Gets the raw value of the JsonValue.
| ||||||||||
int | hashCode() | ||||||||||
boolean |
isBoolean()
Checks if the value is a Boolean.
| ||||||||||
boolean |
isDouble()
Checks if the value is a Double.
| ||||||||||
boolean |
isFloat()
Checks if the value is a Float.
| ||||||||||
boolean |
isInteger()
Checks if the value is an Integer.
| ||||||||||
boolean |
isJsonList()
Checks if the value is a JsonList.
| ||||||||||
boolean |
isJsonMap()
Checks if the value is a JsonMap.
| ||||||||||
boolean |
isLong()
Checks if the value is a Long.
| ||||||||||
boolean |
isNull()
If the contained value is null.
| ||||||||||
boolean |
isNumber()
Checks if the value is a Number.
| ||||||||||
boolean |
isString()
Checks if the value is a String.
| ||||||||||
JsonList |
optList()
Gets the contained values as a JsonList.
| ||||||||||
JsonMap |
optMap()
Gets the contained values as a JsonMap.
| ||||||||||
String |
optString()
Returns the String value or an empty String.
| ||||||||||
static JsonValue |
parseString(String jsonString)
Parse a JSON encoded String.
| ||||||||||
JsonList |
requireList()
Requires the value to be a JsonList or a JsonException will be thrown.
| ||||||||||
JsonMap |
requireMap()
Requires the value to be a JsonMap or a JsonException will be thrown.
| ||||||||||
String |
requireString()
Requires the value to be a String or a JsonException will be thrown.
| ||||||||||
JsonValue |
toJsonValue()
Returns the objects represented as a JsonValue.
| ||||||||||
String |
toString()
Returns the JsonValue as a JSON encoded String.
| ||||||||||
static JsonValue |
wrap(Object object, JsonValue defaultValue)
Wraps any valid object into a JsonValue.
| ||||||||||
static JsonValue |
wrap(double value)
Wraps a double as a JsonValue.
| ||||||||||
static JsonValue |
wrap(boolean value)
Wraps a boolean as a JsonValue.
| ||||||||||
static JsonValue |
wrap(long value)
Wraps a long as a JsonValue.
| ||||||||||
static JsonValue |
wrap(int value)
Wraps an int as a JsonValue.
| ||||||||||
static JsonValue |
wrap(Object object)
Wraps any valid object into a JsonValue.
| ||||||||||
static JsonValue |
wrap(String value)
Wraps a String as a JsonValue.
| ||||||||||
static JsonValue |
wrap(char value)
Wraps a char as a JsonValue.
| ||||||||||
static JsonValue |
wrap(JsonSerializable value)
Wraps a JsonSerializable object as a JsonValue.
| ||||||||||
static JsonValue |
wrapOpt(Object object)
Wraps any valid object into a JsonValue.
| ||||||||||
void | writeToParcel(Parcel dest, int flags) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.os.Parcelable
| |||||||||||
From interface
com.urbanairship.json.JsonSerializable
|
Gets the contained value coerced into a String.
Gets the contained values as a boolean.
defaultValue | The default value if the contained value is not a boolean. |
---|
Gets the contained values as a boolean.
Gets the contained values as an double.
defaultValue | The default value if the contained value is not a number. |
---|
Gets the contained values as a float.
defaultValue | The default value if the contained value is not a number. |
---|
Gets the contained values as an int.
defaultValue | The default value if the contained value is not a number. |
---|
Gets the contained values as an Integer.
Gets the contained value as a JsonList.
Gets the contained values as an long.
defaultValue | The default value if the contained value is not a number. |
---|
Gets the contained values as a JsonMap.
Gets the contained values as a Number.
Gets the contained value as a String.
Gets the contained values as a String.
defaultValue | The default value if the contained value is not a String. |
---|
Gets the raw value of the JsonValue. Will be either a String, Boolean, Long, Double, Integer, JsonMap, JsonArray, or null.
Checks if the value is a Boolean.
true
if the value is a Boolean, otherwise false
.
Checks if the value is a Double.
true
if the value is a Double, otherwise false
.
Checks if the value is a Float.
true
if the value is a Float, otherwise false
.
Checks if the value is an Integer.
true
if the value is an Integer, otherwise false
.
Checks if the value is a JsonList.
true
if the value is a JsonList, otherwise false
.
Checks if the value is a JsonMap.
true
if the value is a JsonMap, otherwise false
.
Checks if the value is a Long.
true
if the value is a Long, otherwise false
.
If the contained value is null.
true
if the contained value is null, otherwise false
.
Checks if the value is a Number.
true
if the value is a Number, otherwise false
.
Checks if the value is a String.
true
if the value is a String, otherwise false
.
Gets the contained values as a JsonList.
Gets the contained values as a JsonMap.
Returns the String value or an empty String.
Parse a JSON encoded String.
jsonString | The json encoded String. |
---|
JsonException | If the JSON was unable to be parsed. |
---|
Requires the value to be a JsonList or a JsonException will be thrown.
JsonException |
---|
Requires the value to be a JsonMap or a JsonException will be thrown.
JsonException |
---|
Requires the value to be a String or a JsonException will be thrown.
JsonException |
---|
Returns the objects represented as a JsonValue.
Returns the JsonValue as a JSON encoded String.
Wraps any valid object into a JsonValue. If the object is unable to be wrapped, the default
value will be returned. See wrap(Object)
for rules on object wrapping.
object | The object to wrap. |
---|---|
defaultValue | The default value if the object is unable to be wrapped. |
Wraps a double as a JsonValue.
value | The value as a double. |
---|
Wraps a boolean as a JsonValue.
value | The value as a boolean. |
---|
Wraps a long as a JsonValue.
value | The value as a long. |
---|
Wraps an int as a JsonValue.
value | The value as an int. |
---|
Wraps any valid object into a JsonValue.
Objects will be wrapped with the following rules:
NULL
.JsonSerializable
will return toJsonValue()
or NULL
.object | The object to wrap. |
---|
JsonException | If the object is not a supported type or contains an unsupported type. |
---|
Wraps a String as a JsonValue.
value | The value as a string. |
---|
Wraps a char as a JsonValue.
value | The value as a char. |
---|
Wraps a JsonSerializable object as a JsonValue.
value | The value as a JsonSerializable object. |
---|