List of usage examples for com.google.gson JsonSyntaxException JsonSyntaxException
public JsonSyntaxException(Throwable cause)
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the string value of the field on the JsonObject with the given name. */// w w w .j av a 2s .c o m public static String getString(JsonObject json, String memberName) { if (json.has(memberName)) { return getString(json.get(memberName), memberName); } else { throw new JsonSyntaxException("Missing " + memberName + ", expected to find a string"); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the boolean value of the given JsonElement. Expects the second parameter to be the name of the element's * field if an error message needs to be thrown. */// w ww . ja va 2 s. co m public static boolean getBoolean(JsonElement json, String memberName) { if (json.isJsonPrimitive()) { return json.getAsBoolean(); } else { throw new JsonSyntaxException("Expected " + memberName + " to be a Boolean, was " + toString(json)); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the boolean value of the field on the JsonObject with the given name. *///from ww w . j av a 2 s. c om public static boolean getBoolean(JsonObject json, String memberName) { if (json.has(memberName)) { return getBoolean(json.get(memberName), memberName); } else { throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Boolean"); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the float value of the given JsonElement. Expects the second parameter to be the name of the element's * field if an error message needs to be thrown. */// www.j a v a 2 s . c o m public static float getFloat(JsonElement json, String memberName) { if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber()) { return json.getAsFloat(); } else { throw new JsonSyntaxException("Expected " + memberName + " to be a Float, was " + toString(json)); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the float value of the field on the JsonObject with the given name. *///ww w. j a v a 2 s .c o m public static float getFloat(JsonObject json, String memberName) { if (json.has(memberName)) { return getFloat(json.get(memberName), memberName); } else { throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Float"); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the integer value of the given JsonElement. Expects the second parameter to be the name of the element's * field if an error message needs to be thrown. *//*ww w. j av a2 s .c o m*/ public static int getInt(JsonElement json, String memberName) { if (json.isJsonPrimitive() && json.getAsJsonPrimitive().isNumber()) { return json.getAsInt(); } else { throw new JsonSyntaxException("Expected " + memberName + " to be a Int, was " + toString(json)); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the integer value of the field on the JsonObject with the given name. *///from w w w. j a v a2 s . co m public static int getInt(JsonObject json, String memberName) { if (json.has(memberName)) { return getInt(json.get(memberName), memberName); } else { throw new JsonSyntaxException("Missing " + memberName + ", expected to find a Int"); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the given JsonElement as a JsonObject. Expects the second parameter to be the name of the element's field * if an error message needs to be thrown. *///from w ww.j av a 2 s. c om public static JsonObject getJsonObject(JsonElement json, String memberName) { if (json.isJsonObject()) { return json.getAsJsonObject(); } else { throw new JsonSyntaxException("Expected " + memberName + " to be a JsonObject, was " + toString(json)); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
public static JsonObject getJsonObject(JsonObject json, String memberName) { if (json.has(memberName)) { return getJsonObject(json.get(memberName), memberName); } else {// ww w . java 2 s .c o m throw new JsonSyntaxException("Missing " + memberName + ", expected to find a JsonObject"); } }
From source file:net.daporkchop.toobeetooteebot.text.JsonUtils.java
License:Open Source License
/** * Gets the given JsonElement as a JsonArray. Expects the second parameter to be the name of the element's field if * an error message needs to be thrown./*from ww w. j av a 2 s .c o m*/ */ public static JsonArray getJsonArray(JsonElement json, String memberName) { if (json.isJsonArray()) { return json.getAsJsonArray(); } else { throw new JsonSyntaxException("Expected " + memberName + " to be a JsonArray, was " + toString(json)); } }