public class JsonUtils
extends java.lang.Object
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
ensureContains(com.google.gson.JsonObject object,
java.lang.String... names)
Ensure the given JsonObject contains the given elements.
|
static com.google.gson.JsonArray |
ensureContainsArray(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given JsonArray element.
|
static boolean |
ensureContainsBoolean(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given boolean element.
|
static float |
ensureContainsFloat(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given float element.
|
static int |
ensureContainsInt(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given int element.
|
static com.google.gson.JsonObject |
ensureContainsObject(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given JsonObject element.
|
static java.lang.String |
ensureContainsString(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given string element.
|
static java.lang.String[] |
ensureContainsStringArray(com.google.gson.JsonObject object,
java.lang.String name)
Ensure the given JsonObject contains the given string array element.
|
static com.google.gson.JsonObject |
ensureRootObject(com.google.gson.JsonElement element,
java.lang.String name)
Ensure that the given element is a JsonObject.
|
static boolean |
hasNonNull(com.google.gson.JsonObject ob,
java.lang.String name)
Check if the given object has the given element and it is not null.
|
public static boolean hasNonNull(com.google.gson.JsonObject ob,
java.lang.String name)
ob - The object to checkname - The name of the elementpublic static com.google.gson.JsonObject ensureRootObject(com.google.gson.JsonElement element,
java.lang.String name)
throws com.google.gson.JsonParseException
element - The element to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is not a JsonObjectpublic static void ensureContains(com.google.gson.JsonObject object,
java.lang.String... names)
throws com.google.gson.JsonParseException
object - The JsonObject to checknames - The names of the elementscom.google.gson.JsonParseException - If one of the elements is missingpublic static java.lang.String ensureContainsString(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a stringpublic static boolean ensureContainsBoolean(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a booleanpublic static int ensureContainsInt(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not an intpublic static float ensureContainsFloat(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a floatpublic static com.google.gson.JsonObject ensureContainsObject(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a JsonObjectpublic static com.google.gson.JsonArray ensureContainsArray(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a JsonArraypublic static java.lang.String[] ensureContainsStringArray(com.google.gson.JsonObject object,
java.lang.String name)
throws com.google.gson.JsonParseException
object - The JsonObject to checkname - The name of the elementcom.google.gson.JsonParseException - If the element is missing or not a string array