NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Maven Central · #658 by repository stars
Last release 5 months ago
23 Apr 2026
Release timing varies
gaps range from 2 weeks to 1.4 years
Nearly every release is documented
notes for 42 of 43 stable releases
Nothing withdrawn
no release was ever pulled
18 years old
44 releases · first in 2008
Add type adapters for java.time classes by @eamonnmcmanus in #2948
Add type adapters for java.time classes by @eamonnmcmanus in #2948
When the java.time API is available, Gson automatically can read and write instances of classes like Instant and Duration. The format it uses essentially freezes the JSON representation that ReflectiveTypeAdapterFactory established by default, based on the private fields of java.time classes. That's not a great representation, but it is understandable. Changing it to anything else would break compatibility with systems that are expecting the current format.
With this change, Gson no longer tries to access private fields of these classes using reflection. So it is no longer necessary to run with --add-opens for these classes on recent JDKs.
Remove com.google.gson.graph by @eamonnmcmanus in #2990.
This package was not part of any released artifact and depended on Gson internals in potentially problematic ways.
Validate that strings being parsed as integers consist of ASCII characters by @eamonnmcmanus in #2995
Previously, strings could contain non-ASCII Unicode digits and still be parsed as integers. That's inconsistent with how JSON numbers are treated.
Fix duplicate key detection when first value is null by @andrewstellman in #3006
This could potentially break code that was relying on the incorrect behaviour. For example, this JSON string was previously accepted but will no longer be: {"foo": null, "foo": bar}.
Remove Serializable from internal Type implementation classes. by @eamonnmcmanus in #3011
The nested classes ParameterizedTypeImpl, GenericArrayTypeImpl, and WildcardTypeImpl in GsonTypes are implementations of the corresponding types (without Impl) in java.lang.reflect. For some reason, they were serializable, even though the java.lang.reflect implementations are not. Having unnecessarily serializable classes could conceivably have been a security problem if they were part of a larger exploit using serialization. (We do not consider this a likely scenario and do not suggest that you need to update Gson just to get this change.)
Add LegacyProtoTypeAdapterFactory. by @eamonnmcmanus in #3014
This is not part of any released artifact, but may be of use when trying to fix code that is currently accessing the internals of protobuf classes via reflection.
Make AppendableWriter do flush and close if delegation object supports by @MukjepScarlet in #2925
new Gson() by @MukjepScarlet in #2864Full Changelog: gson-parent-2.13.2...gson-parent-2.14.0
One column per quarter.
The main changes in this release are just newer dependencies.
The main changes in this release are just newer dependencies.
com.google.gson. See issue #2679.GsonPreconditions by @Marcono1234 in #2879Full Changelog: gson-parent-2.13.1...gson-parent-2.13.2
Nothing published for this version
Give FieldNamingStrategy the ability to return multiple String names by @mfriesen in #2776
com.google.errorprone:error_prone_annotations:2.37.0.Full Changelog: gson-parent-2.13.0...gson-parent-2.13.1
A bug in deserializing collections has been fixed. Previously, if you did something like this:
A bug in deserializing collections has been fixed. Previously, if you did something like this:
gson.fromJson(jsonString, new TypeToken<ImmutableList<String>>() {})
then the inferred type would be ImmutableList<String>, but Gson actually gave you an ArrayList<String>. Usually that would lead to an immediate ClassCastException, but in some circumstances the code might sometimes succeed despite the wrong type. Now you will see an exception like this:
com.google.gson.JsonIOException: Abstract classes can't be instantiated!
Adjust the R8 configuration or register an InstanceCreator or a TypeAdapter for this type.
Class name: com.google.common.collect.ImmutableList
because Gson now really is trying to create an ImmutableList through its constructor, but that isn't possible.
Either change the requested type (in the TypeToken) to List<String>, or register a TypeAdapter or JsonDeserializer for ImmutableList.
The internal classes $Gson$Types and $Gson$Preconditions have been renamed to remove the $ characters. Since these are internal classes (as signaled not only by the package name but by the $ characters), client code should not be affected. If your code was depending on these classes then we suggest making a copy of the class (subject to the license) rather than depending on the new names.
Full Changelog: gson-parent-2.12.1...gson-parent-2.13.0
The only difference between this release and 2.12.0 is that OSGi declarations in the Gson jar now specify that com.google.errorprone.annotations is an
The only difference between this release and 2.12.0 is that OSGi declarations in the Gson jar now specify that com.google.errorprone.annotations is an optional dependency, not a required one. If you do not use OSGi then there is no effective change.
The biggest change is that we no longer support Java 7. People who still need to run on Java 7 will need to use an earlier version of Gson.
The biggest change is that we no longer support Java 7. People who still need to run on Java 7 will need to use an earlier version of Gson.
Other changes:
JsonElement again by @Marcono1234 in #2789JsonReader by @Marcono1234 in #2588@CheckReturnValue to our packages. by @cpovirk in #2693AccessController usage for enum adapter by @Marcono1234 in #2704JsonElement adapter classes to separate class files by @Marcono1234 in #2727Full Changelog: gson-parent-2.11.0...gson-parent-2.12.0
Added default ProGuard / R8 rules ( @Marcono1234 , #2397 , #2420 ; @sgjesse , #2448 ; @sfreilich ) If you are using ProGuard or R8 (for example for An
@SerializedName for their fields.Strictness API (@marten-voorberg & fellow students, #2437)GsonBuilder#setStrictness, JsonReader#setStrictness and JsonWriter#setStrictness with Strictness.STRICT to override this behavior and to instead strictly adhere to the JSON specification when parsing.FormattingStyle class to allow configuring line breaks in JSON output (@mihnita, #2231)GsonBuilder#setFormattingStyle and JsonWriter#setFormattingStyle.TypeToken can no longer capture type variables by default (@Marcono1234, #2376)List implementations returned by libraries such as Guava which are implemented as anonymous class, which were previously serialized as null. Anonymous and local classes without custom adapter will still be serialized as null.com.google.errorprone:error_prone_annotationsJsonElement#toString produces JSON output (@Marcono1234, #2659)JsonPrimitive#equals results for large BigInteger values (@MaicolAntali, #2311)JsonPrimitive#equals results for large BigDecimal values (@MaicolAntali, #2364)JsonReader throwing NumberFormatException instead of MalformedJsonException for malformed Unicode escape sequences (@MaicolAntali, #2337)TypeToken#getParameterized returning bogus ParameterizedType for non-generic types (@Marcono1234, #2447)JsonWriter#name not throwing exception when no JSON object is currently being written (@shivam-sehgal, #2475; @Marcono1234, #2476)Gson#getDelegateAdapter not working properly for @JsonAdapter (@Marcono1234, #2435)null is now not allowed as skipPast value anymore, which was previously allowed but undocumented.GsonBuilder not rejecting type adapters for Object and JsonElement, whose default adapters cannot be overridden (@sachinp97; #2479)BigDecimal and BigInteger (@Marcono1234, #2510)GsonBuilder#setDateFormat not rejecting invalid date formats (@Carpe-Wang, #2538)GsonBuilder#setDateFormat not rejecting invalid date styles (@Marcono1234, #2545)GsonBuilder#setDateFormat ignoring partial DEFAULT style (@Marcono1234, #2556)TypeToken#isAssignableFrom throwing AssertionError in some cases (@Marcono1234, #2544)TypeToken#equals erroneously returning false for equal generic type parameters in some cases (@d-william, #2599)pom.xml (@Marcono1234, #2351)ToNumberPolicy#LONG_OR_DOUBLE (@ctasada, #2674)DateTypeAdapter class to reduce code duplication (@Marcono1234, #2546)master to main@CanIgnoreReturnValue as appropriate to Gson methods (@eamonnmcmanus, #2369)CheckReturnValue in your project when compiling, however Gson itself does not enable this by default.Many thanks to @Marcono1234 for drafting these release notes.
This is technically a minor release rather than a patch release because there is one small API change: a new JsonObject.isEmpty() method.
This is technically a minor release rather than a patch release because there is one small API change: a new JsonObject.isEmpty() method.
final keyword from private method by @MaicolAntali in #2276testParsingDatesFormattedWithSystemLocale(), Fix #2199 by @MaicolAntali in #2287Full Changelog: gson-parent-2.10...gson-parent-2.10.1
Deprecate JsonElement constructor by @Marcono1234 in #1761
Support for serializing and deserializing Java records, on Java ≥ 16. (#2201)
Add JsonArray.asList and JsonObject.asMap view methods (#2225)
Fix TypeAdapterRuntimeTypeWrapper not detecting reflective TreeTypeAdapter and FutureTypeAdapter (#1787)
Improve JsonReader.skipValue() (#2062)
Perform numeric conversion for primitive numeric type adapters (#2158)
Add Gson.fromJson(..., TypeToken) overloads (#1700)
Fix changes to GsonBuilder affecting existing Gson instances (#1815)
Make JsonElement conversion methods more consistent and fix javadoc (#2178)
Throw UnsupportedOperationException when JsonWriter.jsonValue is not supported (#1651)
Disallow JsonObject Entry.setValue(null) (#2167)
Fix TypeAdapter.toJson throwing AssertionError for custom IOException (#2172)
Convert null to JsonNull for JsonArray.set (#2170)
Fixed nullSafe usage. (#1555)
Validate TypeToken.getParameterized arguments (#2166)
Fix #1702: Gson.toJson creates CharSequence which does not implement toString (#1703)
Prefer existing adapter for concurrent Gson.getAdapter calls (#2153)
Improve ArrayTypeAdapter for Object[] (#1716)
Improve AppendableWriter performance (#1706)
Gson.getAdapter calls by @Marcono1234 in #2153TypeToken.getParameterized arguments by @Marcono1234 in #2166JsonArray.set by @Marcono1234 in #2170GsonBuilder.setExclusionStrategies does not replace existing ones by @Marcono1234 in #2168TypeAdapter.toJson throwing AssertionError for custom IOException by @Marcono1234 in #2172JsonObject Entry.setValue(null) by @Marcono1234 in #2167$Gson$Preconditions.checkNotNull with Objects.requireNonNull by @Marcono1234 in #2180ReleaseProcess.md by @Marcono1234 in #2159@Ignore it. by @eamonnmcmanus in #2203@since tags for previously added elements by @Marcono1234 in #2211JsonReader.skipValue() by @Marcono1234 in #2062JsonArray.asList and JsonObject.asMap view methods by @Marcono1234 in #2225release:prepare by @Marcono1234 in #2212GsonVersionDiagnosticsTest. by @eamonnmcmanus in #2228Full Changelog: gson-parent-2.9.1...gson-parent-2.10
JsonArray.asList and JsonObject.asMap view methods (https://github.com/google/gson/pull/2225)TypeAdapterRuntimeTypeWrapper not detecting reflective TreeTypeAdapter and FutureTypeAdapter (https://github.com/google/gson/pull/1787)JsonReader.skipValue() (https://github.com/google/gson/pull/2062)Gson.fromJson(..., TypeToken) overloads (https://github.com/google/gson/pull/1700)GsonBuilder affecting existing Gson instances (https://github.com/google/gson/pull/1815)JsonElement conversion methods more consistent and fix javadoc (https://github.com/google/gson/pull/2178)UnsupportedOperationException when JsonWriter.jsonValue is not supported (https://github.com/google/gson/pull/1651)JsonObject Entry.setValue(null) (https://github.com/google/gson/pull/2167)TypeAdapter.toJson throwing AssertionError for custom IOException (https://github.com/google/gson/pull/2172)JsonArray.set (https://github.com/google/gson/pull/2170)TypeToken.getParameterized arguments (https://github.com/google/gson/pull/2166)Gson.getAdapter calls (https://github.com/google/gson/pull/2153)ArrayTypeAdapter for Object[] (https://github.com/google/gson/pull/1716)AppendableWriter performance (https://github.com/google/gson/pull/1706)Make Object and JsonElement deserialization iterative rather than recursive
Object and JsonElement deserialization iterative rather than
recursive (https://github.com/google/gson/pull/1912)codegen hierarchy (https://github.com/google/gson/pull/2099)TypeToken creation validation (https://github.com/google/gson/pull/2072)float in JsonWriter (https://github.com/google/gson/pull/2130, https://github.com/google/gson/pull/2132)Also many small improvements to javadoc.
The minimum supported Java version changes from 6 to 7.
The minimum supported Java version changes from 6 to 7.
module-info.class into Multi-Release JAR folder (https://github.com/google/gson/pull/2013)GsonBuilder.disableJdkUnsafe() (https://github.com/google/gson/pull/1904)UPPER_CASE_WITH_UNDERSCORES in FieldNamingPolicy (https://github.com/google/gson/pull/2024)Gson.newJsonWriter ignoring lenient and HTML-safe setting (https://github.com/google/gson/pull/1989)FieldNamingPolicy.upperCaseFirstLetter uppercasing non-letter (https://github.com/google/gson/pull/2004)Deprecate Gson.excluder() exposing internal Excluder class (https://github.com/google/gson/pull/1986).
sun.misc optional (https://github.com/google/gson/pull/1993).Gson.excluder() exposing internal Excluder class (https://github.com/google/gson/pull/1986).RuntimeTypeAdapterFactory depending on internal Streams class (https://github.com/google/gson/pull/1959).java.sql optional (https://github.com/google/gson/pull/1707).Fixed issue with recursive types (https://github.com/google/gson/issues/1390).
Unsafe if there is a security manager (https://github.com/google/gson/pull/1712).EnumTypeAdapter now works better when ProGuard has obfuscated enum fields (https://github.com/google/gson/pull/1495).Fixed ISO8601UtilsTest failing on systems with UTC+X.
ISO8601UtilsTest failing on systems with UTC+X.JsonStreamParser.IllegalStateException in JsonTreeWriter (https://github.com/google/gson/issues/1592).JsonArray.isEmpty() (https://github.com/google/gson/pull/1640).Added static methods JsonParser.parseString and JsonParser.parseReader and deprecated instance method JsonParser.parse
2019-10-04 GitHub Diff
JsonParser.parseString and JsonParser.parseReader and deprecated instance method JsonParser.parseMoved utils.VersionUtils class to internal.JavaVersion. This is a potential backward incompatible change from 2.8.4
2018-05-21 GitHub Diff
utils.VersionUtils class to internal.JavaVersion. This is a potential backward incompatible change from 2.8.4Added a new FieldNamingPolicy, LOWER_CASE_WITH_DOTS that maps JSON name someFieldName to some.field.name
2018-05-01 GitHub Diff
LOWER_CASE_WITH_DOTS that maps JSON name someFieldName to some.field.namesun.misc.UnsafeAdded a new API, GsonBuilder.newBuilder() that clones the current builder
2018-04-27 GitHub Diff
GsonBuilder.newBuilder() that clones the current builderIntroduced a new API, JsonElement.deepCopy()
2017-09-19 GitHub Diff
JsonElement.deepCopy()@JsonAdapter annotation can now use JsonSerializer and JsonDeserializer as well.
2017-05-30 GitHub Diff
JsonObject.keySet()@JsonAdapter annotation can now use JsonSerializer and JsonDeserializer as well.Nothing published for this version
Added support for JsonSerializer/JsonDeserializer in @JsonAdapter annotation
2016-06-14 GitHub Diff
Fixed an NPE bug with @JsonAdapter annotation
2016-02-26 GitHub Diff
Fix: The 2.6 release targeted Java 1.7, but we intend to target Java 1.6. The 2.6.1 release is identical to 2.6, but it targets Java 1.6.
2016-02-11 GitHub Diff
Permit timezones without minutes in the default date adapter.
2016-02-11 GitHub Diff
setLenient() method on GsonBuilder. This setting impacts the new
factory method Gson.newJsonReader().@JsonAdapter are now null safe by default.Updated minimum JDK version to 1.6
2015-11-24 GitHub Diff
java.util.Currency, AtomicLong, AtomicLongArray, AtomicInteger, AtomicIntegerArray, AtomicBoolean. This change is backward-incompatible because the earlier version of Gson used the default serialization which wasn't intuitive. We hope that these classes are not used enough to actually cause problems in the field.Drop `IOException` from `TypeAdapter.toJson()`. This is a binary-compatible change, but may cause compiler errors where IOExceptions are being caught
2015-10-04
IOException from TypeAdapter.toJson(). This is a binary-compatible change, but may
cause compiler errors where IOExceptions are being caught but no longer thrown. The correct fix
for this problem is to remove the unnecessary catch clause.Gson.newJsonWriter method returns configured JsonWriter instances.@SerializedName now works with [AutoValue’s][autovalue] abstract property methods.@SerializedName permits alternate names when deserializing.JsonWriter#jsonValue writes raw JSON values.JsonArray instances.FieldNamingPolicy now works properly when running on a device with a Turkish locale.
[autovalue]: https://github.com/google/auto/tree/main/valueAdded support to serialize objects with self-referential fields. The self-referential field is set to null in JSON. Previous version of Gson threw a S
2014-11-20
The new @JsonAdapter annotation to specify a Json TypeAdapter for a class field
2014-08-11
contains(JsonElement), remove(JsonElement), remove(int index), set(int index, JsonElement element)Fix internal map (LinkedHashTreeMap) hashing bug.
2013-05-13
Fixes for possible DoS attack due to poor String hashing
2013-04-12
Gson now allows a user to override default type adapters for Primitives and Strings. This behavior was allowed in earlier versions of Gson but was pro
2012-07-02
JsonParser): In the past, if JsonParser encountered a stream that terminated prematurely, it returned JsonNull. This behavior wasn't correct because the stream had invalid JSON, not a null. JsonParser is now changed to throw JsonSyntaxException in this case. Note that if JsonParser (or Gson) encounter an empty stream, they still return JsonNull._2012-05-05_ * Very minor fixes
2012-05-05
Added getDelegateAdapter in Gson class
2012-05-05
_2011-12-30_ (Targeted Dec 31, 2011)
2011-12-30 (Targeted Dec 31, 2011)
Previous versions first parsed complete document into a DOM-style model (JsonObject or JsonArray) and then bound data against that. Gson 2 does data b
2011-11-13
Gson 1.7 would serialize top-level nulls as "". 2.0 serializes them as "null".
String json = gson.toJson(null, Foo.class);
1.7: json == ""
2.0: json == "null"
Gson 1.7 permitted duplicate map keys. 2.0 forbids them.
String json = "{'a':1,'a':2}";
Map<String, Integer> map = gson.fromJson(json, mapType);
1.7: map == {a=2}
2.0: JsonSyntaxException thrown
Gson 1.7 won’t serialize subclass fields in collection elements. 2.0 adds this extra information.
List<Point2d> points = new ArrayList<Point2d>();
points.add(new Point3d(1, 2, 3));
String json = gson.toJson(points,
new TypeToken<List<Point2d>>() {}.getType());
1.7: json == "[{'x':1,'y':2}]"
2.0: json == "[{'x':1,'y':2,'z':3}]"
Gson 1.7 binds single-element arrays as their contents. 2.0 doesn’t.
Integer i = gson.fromJson("[42]", Integer.class);
1.7: i == 42
2.0: JsonSyntaxException thrown
_2011-09-30_ (Unplanned release)
2011-09-30 (Unplanned release)
_2011-04-13_ (Unplanned release)
2011-04-13 (Unplanned release)
_2011-04-12_ (Targeted: Jan 2011)
2011-04-12 (Targeted: Jan 2011)
_2010-11-24_ (Targeted: Oct, 2010)
2010-11-24 (Targeted: Oct, 2010)
_2010-08-19_ (Target Date: Aug 18, 2010)
2010-08-19 (Target Date: Aug 18, 2010)
UPPER_CAMEL_CASE_WITH_SPACES naming policyJsonStreamParser: A streaming parser API class to deserialize multiple JSON objects on a stream (such as a pipelined HTTP response)
2009_10_09
Gson.toJsonTree() method that serializes a Java object to a tree of JsonElements. See issue 110.Gson.fromJson(JsonElement) method that deserializes from a Json parse tree.Expose annotation to contain parameters serialize and deserialize to control whether a field gets serialized or deserialized. See issue 146.LOWER_CASE_WITH_DASHESJsonElement.toString() now outputs valid JSON after escaping characters properly. See issue 154.JsonPrimitive.equals() now returns true for two numbers if their values are equal. All integral types (long, int, short, byte, BigDecimal, Long, Integer, Short, Byte) are treated equivalent for comparison. Similarly, floating point types (double, float, BigDecimal, Double, Float) are treated equivalent as well. See issue 147._2008-07-01_ (Target Date Thursday, July 3, 2008)
2008-07-01 (Target Date Thursday, July 3, 2008)
Your coding agent can read these notes before it upgrades. Set up the MCP server →