public class JsonHelper extends Object
Constructor and Description |
---|
JsonHelper() |
Modifier and Type | Method and Description |
---|---|
static JsonArray |
asArray(JsonElement element,
String name) |
static boolean |
asBoolean(JsonElement element,
String name) |
static byte |
asByte(JsonElement element,
String name) |
static float |
asFloat(JsonElement element,
String name) |
static int |
asInt(JsonElement element,
String name) |
static Item |
asItem(JsonElement element,
String name) |
static long |
asLong(JsonElement element,
String name) |
static JsonObject |
asObject(JsonElement element,
String name) |
static String |
asString(JsonElement element,
String name) |
static <T> T |
deserialize(Gson gson,
Reader reader,
Class<T> class2) |
static <T> T |
deserialize(Gson gson,
Reader reader,
Class<T> type,
boolean lenient) |
static <T> T |
deserialize(Gson gson,
Reader reader,
TypeToken<T> typeToken) |
static <T> T |
deserialize(Gson gson,
Reader reader,
TypeToken<T> typeToken,
boolean lenient) |
static <T> T |
deserialize(Gson gson,
String content,
Class<T> class2) |
static <T> T |
deserialize(Gson gson,
String content,
Class<T> class2,
boolean lenient) |
static <T> T |
deserialize(Gson gson,
String content,
TypeToken<T> typeToken) |
static <T> T |
deserialize(Gson gson,
String content,
TypeToken<T> typeToken,
boolean lenient) |
static <T> T |
deserialize(JsonElement element,
String name,
JsonDeserializationContext context,
Class<? extends T> type) |
static <T> T |
deserialize(JsonObject object,
String element,
JsonDeserializationContext context,
Class<? extends T> type) |
static <T> T |
deserialize(JsonObject object,
String element,
T defaultValue,
JsonDeserializationContext context,
Class<? extends T> type) |
static JsonObject |
deserialize(Reader reader) |
static JsonObject |
deserialize(Reader reader,
boolean lenient) |
static JsonObject |
deserialize(String content) |
static JsonObject |
deserialize(String content,
boolean lenient) |
static JsonArray |
getArray(JsonObject object,
String element) |
static JsonArray |
getArray(JsonObject object,
String name,
JsonArray defaultArray) |
static boolean |
getBoolean(JsonObject object,
String element) |
static boolean |
getBoolean(JsonObject object,
String element,
boolean defaultBoolean) |
static byte |
getByte(JsonObject object,
String element,
byte defaultByte) |
static float |
getFloat(JsonObject object,
String element) |
static float |
getFloat(JsonObject object,
String element,
float defaultFloat) |
static int |
getInt(JsonObject object,
String element) |
static int |
getInt(JsonObject object,
String element,
int defaultInt) |
static Item |
getItem(JsonObject object,
String key) |
static long |
getLong(JsonObject object,
String name) |
static long |
getLong(JsonObject object,
String element,
long defaultLong) |
static JsonObject |
getObject(JsonObject object,
String element) |
static JsonObject |
getObject(JsonObject object,
String element,
JsonObject defaultObject) |
static String |
getString(JsonObject object,
String element) |
static String |
getString(JsonObject object,
String element,
String defaultStr) |
static String |
getType(JsonElement element) |
static boolean |
hasArray(JsonObject object,
String element) |
static boolean |
hasBoolean(JsonObject object,
String element) |
static boolean |
hasElement(JsonObject object,
String lement) |
static boolean |
hasPrimitive(JsonObject object,
String element) |
static boolean |
hasString(JsonObject object,
String element) |
static boolean |
isNumber(JsonElement element) |
static boolean |
isString(JsonElement element) |
private static final Gson GSON
public static boolean hasString(JsonObject object, String element)
@Environment(value=CLIENT) public static boolean isString(JsonElement element)
public static boolean isNumber(JsonElement element)
@Environment(value=CLIENT) public static boolean hasBoolean(JsonObject object, String element)
public static boolean hasArray(JsonObject object, String element)
public static boolean hasPrimitive(JsonObject object, String element)
public static boolean hasElement(JsonObject object, String lement)
public static String asString(JsonElement element, String name)
public static String getString(JsonObject object, String element)
public static String getString(JsonObject object, String element, String defaultStr)
public static Item asItem(JsonElement element, String name)
public static Item getItem(JsonObject object, String key)
public static boolean asBoolean(JsonElement element, String name)
public static boolean getBoolean(JsonObject object, String element)
public static boolean getBoolean(JsonObject object, String element, boolean defaultBoolean)
public static float asFloat(JsonElement element, String name)
public static float getFloat(JsonObject object, String element)
public static float getFloat(JsonObject object, String element, float defaultFloat)
public static long asLong(JsonElement element, String name)
public static long getLong(JsonObject object, String name)
public static long getLong(JsonObject object, String element, long defaultLong)
public static int asInt(JsonElement element, String name)
public static int getInt(JsonObject object, String element)
public static int getInt(JsonObject object, String element, int defaultInt)
public static byte asByte(JsonElement element, String name)
public static byte getByte(JsonObject object, String element, byte defaultByte)
public static JsonObject asObject(JsonElement element, String name)
public static JsonObject getObject(JsonObject object, String element)
public static JsonObject getObject(JsonObject object, String element, JsonObject defaultObject)
public static JsonArray asArray(JsonElement element, String name)
public static JsonArray getArray(JsonObject object, String element)
@Nullable public static JsonArray getArray(JsonObject object, String name, @Nullable JsonArray defaultArray)
public static <T> T deserialize(@Nullable JsonElement element, String name, JsonDeserializationContext context, Class<? extends T> type)
public static <T> T deserialize(JsonObject object, String element, JsonDeserializationContext context, Class<? extends T> type)
public static <T> T deserialize(JsonObject object, String element, T defaultValue, JsonDeserializationContext context, Class<? extends T> type)
public static String getType(JsonElement element)
@Nullable public static <T> T deserialize(Gson gson, Reader reader, Class<T> type, boolean lenient)
@Environment(value=CLIENT) @Nullable public static <T> T deserialize(Gson gson, Reader reader, TypeToken<T> typeToken, boolean lenient)
@Environment(value=CLIENT) @Nullable public static <T> T deserialize(Gson gson, String content, TypeToken<T> typeToken, boolean lenient)
@Nullable public static <T> T deserialize(Gson gson, String content, Class<T> class2, boolean lenient)
@Environment(value=CLIENT) @Nullable public static <T> T deserialize(Gson gson, Reader reader, TypeToken<T> typeToken)
@Environment(value=CLIENT) @Nullable public static <T> T deserialize(Gson gson, String content, TypeToken<T> typeToken)
public static JsonObject deserialize(String content, boolean lenient)
public static JsonObject deserialize(Reader reader, boolean lenient)
public static JsonObject deserialize(String content)
public static JsonObject deserialize(Reader reader)