public final class JsonUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Map<String,Comparable> |
fromJsonObject(JsonObject object)
Transforms the provided
JsonObject int a map of name/value pairs. |
static JsonArray |
getArray(JsonObject object,
String field)
Returns a field in a Json object as an array.
|
static JsonArray |
getArray(JsonObject object,
String field,
JsonArray defaultValue)
Returns a field in a Json object as an array.
|
static boolean |
getBoolean(JsonObject object,
String field)
Returns a field in a Json object as a boolean.
|
static boolean |
getBoolean(JsonObject object,
String field,
boolean defaultValue)
Returns a field in a Json object as a boolean.
|
static double |
getDouble(JsonObject object,
String field)
Returns a field in a Json object as a double.
|
static double |
getDouble(JsonObject object,
String field,
double defaultValue)
Returns a field in a Json object as a double.
|
static float |
getFloat(JsonObject object,
String field)
Returns a field in a Json object as a float.
|
static float |
getFloat(JsonObject object,
String field,
float defaultValue)
Returns a field in a Json object as a float.
|
static int |
getInt(JsonObject object,
String field)
Returns a field in a Json object as an int.
|
static int |
getInt(JsonObject object,
String field,
int defaultValue)
Returns a field in a Json object as an int.
|
static long |
getLong(JsonObject object,
String field)
Returns a field in a Json object as a long.
|
static long |
getLong(JsonObject object,
String field,
long defaultValue)
Returns a field in a Json object as a long.
|
static JsonObject |
getObject(JsonObject object,
String field)
Returns a field in a Json object as an object.
|
static JsonObject |
getObject(JsonObject object,
String field,
JsonObject defaultValue)
Returns a field in a Json object as an object.
|
static String |
getString(JsonObject object,
String field)
Returns a field in a Json object as a string.
|
static String |
getString(JsonObject object,
String field,
String defaultValue)
Returns a field in a Json object as a string.
|
static String |
toJson(Object value)
Returns the JSON representation of the provided
value |
static JsonObject |
toJsonObject(Map<String,?> map)
Transforms the provided map of name/value pairs into a
JsonObject . |
public static int getInt(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static int getInt(JsonObject object, String field, int defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static long getLong(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static long getLong(JsonObject object, String field, long defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static double getDouble(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static double getDouble(JsonObject object, String field, double defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static float getFloat(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static float getFloat(JsonObject object, String field, float defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static String getString(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static String getString(JsonObject object, String field, String defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static boolean getBoolean(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static boolean getBoolean(JsonObject object, String field, boolean defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static JsonArray getArray(JsonObject object, String field)
object
- the Json Objectfield
- the field in the Json object to returnpublic static JsonArray getArray(JsonObject object, String field, JsonArray defaultValue)
object
- the Json Objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static JsonObject getObject(JsonObject object, String field)
object
- the Json objectfield
- the field in the Json object to returnpublic static JsonObject getObject(JsonObject object, String field, JsonObject defaultValue)
object
- the Json objectfield
- the field in the Json object to returndefaultValue
- a default value for the field if the field value is nullpublic static Map<String,Comparable> fromJsonObject(JsonObject object)
JsonObject
int a map of name/value pairs.object
- the JSON objectpublic static JsonObject toJsonObject(Map<String,?> map)
JsonObject
.map
- map of JSON name-value pairsCopyright © 2019 Hazelcast, Inc.. All Rights Reserved.