Class GsonHelper

java.lang.Object
net.minecraft.util.GsonHelper

public class GsonHelper extends Object
  • Field Details

    • GSON

      private static final com.google.gson.Gson GSON
  • Constructor Details

    • GsonHelper

      public GsonHelper()
  • Method Details

    • isStringValue

      public static boolean isStringValue(com.google.gson.JsonObject node, String name)
    • isStringValue

      public static boolean isStringValue(com.google.gson.JsonElement node)
    • isNumberValue

      public static boolean isNumberValue(com.google.gson.JsonObject node, String name)
    • isNumberValue

      public static boolean isNumberValue(com.google.gson.JsonElement node)
    • isBooleanValue

      public static boolean isBooleanValue(com.google.gson.JsonObject node, String name)
    • isBooleanValue

      public static boolean isBooleanValue(com.google.gson.JsonElement node)
    • isArrayNode

      public static boolean isArrayNode(com.google.gson.JsonObject node, String name)
    • isObjectNode

      public static boolean isObjectNode(com.google.gson.JsonObject node, String name)
    • isValidPrimitive

      public static boolean isValidPrimitive(com.google.gson.JsonObject node, String name)
    • isValidNode

      public static boolean isValidNode(@Nullable com.google.gson.JsonObject node, String name)
    • getNonNull

      public static com.google.gson.JsonElement getNonNull(com.google.gson.JsonObject object, String name)
    • convertToString

      public static String convertToString(com.google.gson.JsonElement element, String name)
    • getAsString

      public static String getAsString(com.google.gson.JsonObject object, String name)
    • getAsString

      @Contract("_,_,!null->!null;_,_,null->_") public static @Nullable String getAsString(com.google.gson.JsonObject object, String name, @Nullable String def)
    • convertToItem

      public static Holder<Item> convertToItem(com.google.gson.JsonElement element, String name)
    • getAsItem

      public static Holder<Item> getAsItem(com.google.gson.JsonObject object, String name)
    • getAsItem

      @Contract("_,_,!null->!null;_,_,null->_") public static @Nullable Holder<Item> getAsItem(com.google.gson.JsonObject object, String name, @Nullable Holder<Item> def)
    • convertToBoolean

      public static boolean convertToBoolean(com.google.gson.JsonElement element, String name)
    • getAsBoolean

      public static boolean getAsBoolean(com.google.gson.JsonObject object, String name)
    • getAsBoolean

      public static boolean getAsBoolean(com.google.gson.JsonObject object, String name, boolean def)
    • convertToDouble

      public static double convertToDouble(com.google.gson.JsonElement element, String name)
    • getAsDouble

      public static double getAsDouble(com.google.gson.JsonObject object, String name)
    • getAsDouble

      public static double getAsDouble(com.google.gson.JsonObject object, String name, double def)
    • convertToFloat

      public static float convertToFloat(com.google.gson.JsonElement element, String name)
    • getAsFloat

      public static float getAsFloat(com.google.gson.JsonObject object, String name)
    • getAsFloat

      public static float getAsFloat(com.google.gson.JsonObject object, String name, float def)
    • convertToLong

      public static long convertToLong(com.google.gson.JsonElement element, String name)
    • getAsLong

      public static long getAsLong(com.google.gson.JsonObject object, String name)
    • getAsLong

      public static long getAsLong(com.google.gson.JsonObject object, String name, long def)
    • convertToInt

      public static int convertToInt(com.google.gson.JsonElement element, String name)
    • getAsInt

      public static int getAsInt(com.google.gson.JsonObject object, String name)
    • getAsInt

      public static int getAsInt(com.google.gson.JsonObject object, String name, int def)
    • convertToByte

      public static byte convertToByte(com.google.gson.JsonElement element, String name)
    • getAsByte

      public static byte getAsByte(com.google.gson.JsonObject object, String name)
    • getAsByte

      public static byte getAsByte(com.google.gson.JsonObject object, String name, byte def)
    • convertToCharacter

      public static char convertToCharacter(com.google.gson.JsonElement element, String name)
    • getAsCharacter

      public static char getAsCharacter(com.google.gson.JsonObject object, String name)
    • getAsCharacter

      public static char getAsCharacter(com.google.gson.JsonObject object, String name, char def)
    • convertToBigDecimal

      public static BigDecimal convertToBigDecimal(com.google.gson.JsonElement element, String name)
    • getAsBigDecimal

      public static BigDecimal getAsBigDecimal(com.google.gson.JsonObject object, String name)
    • getAsBigDecimal

      public static BigDecimal getAsBigDecimal(com.google.gson.JsonObject object, String name, BigDecimal def)
    • convertToBigInteger

      public static BigInteger convertToBigInteger(com.google.gson.JsonElement element, String name)
    • getAsBigInteger

      public static BigInteger getAsBigInteger(com.google.gson.JsonObject object, String name)
    • getAsBigInteger

      public static BigInteger getAsBigInteger(com.google.gson.JsonObject object, String name, BigInteger def)
    • convertToShort

      public static short convertToShort(com.google.gson.JsonElement element, String name)
    • getAsShort

      public static short getAsShort(com.google.gson.JsonObject object, String name)
    • getAsShort

      public static short getAsShort(com.google.gson.JsonObject object, String name, short def)
    • convertToJsonObject

      public static com.google.gson.JsonObject convertToJsonObject(com.google.gson.JsonElement element, String name)
    • getAsJsonObject

      public static com.google.gson.JsonObject getAsJsonObject(com.google.gson.JsonObject object, String name)
    • getAsJsonObject

      @Contract("_,_,!null->!null;_,_,null->_") public static @Nullable com.google.gson.JsonObject getAsJsonObject(com.google.gson.JsonObject object, String name, @Nullable com.google.gson.JsonObject def)
    • convertToJsonArray

      public static com.google.gson.JsonArray convertToJsonArray(com.google.gson.JsonElement element, String name)
    • getAsJsonArray

      public static com.google.gson.JsonArray getAsJsonArray(com.google.gson.JsonObject object, String name)
    • getAsJsonArray

      @Contract("_,_,!null->!null;_,_,null->_") public static @Nullable com.google.gson.JsonArray getAsJsonArray(com.google.gson.JsonObject object, String name, @Nullable com.google.gson.JsonArray def)
    • convertToObject

      public static <T> T convertToObject(@Nullable com.google.gson.JsonElement element, String name, com.google.gson.JsonDeserializationContext context, Class<? extends T> clazz)
    • getAsObject

      public static <T> T getAsObject(com.google.gson.JsonObject object, String name, com.google.gson.JsonDeserializationContext context, Class<? extends T> clazz)
    • getAsObject

      @Contract("_,_,!null,_,_->!null;_,_,null,_,_->_") public static <T> @Nullable T getAsObject(com.google.gson.JsonObject object, String name, @Nullable T def, com.google.gson.JsonDeserializationContext context, Class<? extends T> clazz)
    • getType

      public static String getType(@Nullable com.google.gson.JsonElement element)
    • fromJson

      public static <T> T fromJson(com.google.gson.Gson gson, Reader reader, Class<T> type)
    • fromNullableJson

      public static <T> @Nullable T fromNullableJson(com.google.gson.Gson gson, Reader reader, com.google.gson.reflect.TypeToken<T> type)
    • fromJson

      public static <T> T fromJson(com.google.gson.Gson gson, Reader reader, com.google.gson.reflect.TypeToken<T> type)
    • fromNullableJson

      public static <T> @Nullable T fromNullableJson(com.google.gson.Gson gson, String string, com.google.gson.reflect.TypeToken<T> type)
    • fromJson

      public static <T> T fromJson(com.google.gson.Gson gson, String string, Class<T> type)
    • parse

      public static com.google.gson.JsonObject parse(String string)
    • parse

      public static com.google.gson.JsonObject parse(Reader reader)
    • parseArray

      public static com.google.gson.JsonArray parseArray(String string)
    • parseArray

      public static com.google.gson.JsonArray parseArray(Reader reader)
    • toStableString

      public static String toStableString(com.google.gson.JsonElement jsonElement)
    • writeValue

      public static void writeValue(com.google.gson.stream.JsonWriter out, @Nullable com.google.gson.JsonElement value, @Nullable Comparator<String> keyComparator) throws IOException
      Throws:
      IOException
    • sortByKeyIfNeeded

      private static Collection<Map.Entry<String, com.google.gson.JsonElement>> sortByKeyIfNeeded(Collection<Map.Entry<String, com.google.gson.JsonElement>> elements, @Nullable Comparator<String> keyComparator)
    • encodesLongerThan

      public static boolean encodesLongerThan(com.google.gson.JsonElement element, int limit)