Top Deprecated
Gson 2.14.0

Deprecated API


No API in this release is deprecated for removal.

Deprecated Item Summary

SinceDeprecated Item and Description
com.google.gson.Gson.excluder()

This method by accident exposes an internal Gson class; it might be removed in a future version.

Returns:

a reference to this GsonBuilder object to fulfill the "Builder" pattern
com.google.gson.GsonBuilder.setDateFormat
(int
the predefined date style that date objects will be serialized/deserialized to/from
dateStyle
)

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 by setDateFormat(int, int). Therefore prefer using setDateFormat(int, int) and explicitly provide the desired 'time style'.

Returns:

a reference to this GsonBuilder object to fulfill the "Builder" pattern.
com.google.gson.GsonBuilder.setLenient
()

This method is equivalent to calling setStrictness(Strictness) with Strictness#LENIENT: setStrictness(Strictness.LENIENT)

Returns:

this element as a primitive short if it is single element array.
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()

Creating custom JsonElement subclasses is highly discouraged and can lead to undefined behavior.
This constructor is only kept for backward compatibility.

Returns:

the first character of the string value.
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.JsonNull()

Deprecated since Gson version 1.8, use INSTANCE instead.

com.google.gson.JsonParser()

No need to instantiate this class, use the static methods instead.

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<?> cls)

this implementation may be inconsistent with javac for types with wildcards.

com.google.gson.reflect.TypeToken.isAssignableFrom(Type from)

this implementation may be inconsistent with javac for types with wildcards.

com.google.gson.reflect.TypeToken.isAssignableFrom(TypeToken<?> token)

this implementation may be inconsistent with javac for types with wildcards.

com.google.gson.stream.JsonReader.setLenient(boolean
whether this reader should be lenient. If true, the strictness is set to Strictness#LENIENT. If false, the strictness is set to Strictness#LEGACY_STRICT.
lenient
)

Please use setStrictness(Strictness) instead. JsonReader.setLenient(true) should be replaced by JsonReader.setStrictness(Strictness.LENIENT) and JsonReader.setLenient(false) should be replaced by JsonReader.setStrictness(Strictness.LEGACY_STRICT).
However, if you used setLenient(false) before, you might prefer Strictness#STRICT now instead.

com.google.gson.stream.JsonWriter.setLenient(boolean
whether this writer should be lenient. If true, the strictness is set to Strictness#LENIENT. If false, the strictness is set to Strictness#LEGACY_STRICT.
lenient
)

Please use setStrictness(Strictness) instead. JsonWriter.setLenient(true) should be replaced by JsonWriter.setStrictness(Strictness.LENIENT) and JsonWriter.setLenient(false) should be replaced by JsonWriter.setStrictness(Strictness.LEGACY_STRICT).
However, if you used setLenient(false) before, you might prefer Strictness#STRICT now instead.

No API in this release references deprecated elements.