-
Methods Method Description com.google.gson.Gson.excluder() This method by accident exposes an internal Gson class; it might be removed in a future version.com.google.gson.GsonBuilder.setDateFormat(int) Counterintuitively, despite this method taking only a 'date style' Gson will use a format which includes both date and time, with the 'time style' being the last value set byGsonBuilder.setDateFormat(int, int)
. Therefore prefer usingGsonBuilder.setDateFormat(int, int)
and explicitly provide the desired 'time style'.com.google.gson.GsonBuilder.setLenient() This method is equivalent to callingGsonBuilder.setStrictness(Strictness)
withStrictness.LENIENT
:setStrictness(Strictness.LENIENT)
com.google.gson.JsonArray.getAsCharacter() This method is misleading, as it does not get this element as a char but rather as a string's first character.com.google.gson.JsonElement.getAsCharacter() This method is misleading, as it does not get this element as a char but rather as a string's first character.com.google.gson.JsonParser.parse(String) com.google.gson.JsonPrimitive.getAsCharacter() This method is misleading, as it does not get this element as a char but rather as a string's first character.com.google.gson.reflect.TypeToken.isAssignableFrom(Class<?>) this implementation may be inconsistent with javac for types with wildcards.com.google.gson.stream.JsonReader.setLenient(boolean) Please useJsonReader.setStrictness(Strictness)
instead.JsonReader.setLenient(true)
should be replaced byJsonReader.setStrictness(Strictness.LENIENT)
andJsonReader.setLenient(false)
should be replaced byJsonReader.setStrictness(Strictness.LEGACY_STRICT)
.
However, if you usedsetLenient(false)
before, you might preferStrictness.STRICT
now instead.com.google.gson.stream.JsonWriter.setLenient(boolean) Please useJsonWriter.setStrictness(Strictness)
instead.JsonWriter.setLenient(true)
should be replaced byJsonWriter.setStrictness(Strictness.LENIENT)
andJsonWriter.setLenient(false)
should be replaced byJsonWriter.setStrictness(Strictness.LEGACY_STRICT)
.
However, if you usedsetLenient(false)
before, you might preferStrictness.STRICT
now instead.
-
Constructors Constructor Description com.google.gson.JsonElement() Creating customJsonElement
subclasses is highly discouraged and can lead to undefined behavior.
This constructor is only kept for backward compatibility.com.google.gson.JsonNull() Deprecated since Gson version 1.8, useJsonNull.INSTANCE
instead.com.google.gson.JsonParser() No need to instantiate this class, use the static methods instead.