com.google.code.gson:gson
2.14.0
#480 most downloaded on Maven Central
google/gson
What this package is like to depend on
Last release 4 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
3 releases in the last 12 months
see the full history below
Release timeline
44 releases · Aug 2008 to Apr 2026Releases
latest 44-
2.14.023 Apr 2026Release notes
Open source →What's Changed
-
Add type adapters for
java.timeclasses by @eamonnmcmanus in #2948When the
java.timeAPI is available, Gson automatically can read and write instances of classes likeInstantandDuration. The format it uses essentially freezes the JSON representation thatReflectiveTypeAdapterFactoryestablished by default, based on the private fields ofjava.timeclasses. 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-opensfor these classes on recent JDKs. -
Remove
com.google.gson.graphby @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
Serializablefrom internalTypeimplementation classes. by @eamonnmcmanus in #3011The nested classes
ParameterizedTypeImpl,GenericArrayTypeImpl, andWildcardTypeImplinGsonTypesare implementations of the corresponding types (withoutImpl) injava.lang.reflect. For some reason, they were serializable, even though thejava.lang.reflectimplementations 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 #3014This 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
Other less visible changes
- Add default capacity to EnumTypeAdapter maps by @MukjepScarlet in #2959
- refactor: move derived adapters from Gson to TypeAdapters by @MukjepScarlet in #2951
- Optimize
new Gson()by @MukjepScarlet in #2864
New Contributors
- @ThirdGoddess made their first contribution in #2944
- @lmj798 made their first contribution in #2988
- @Eng-YasminKotb made their first contribution in #3005
- @andrewstellman made their first contribution in #3006
Full Changelog: gson-parent-2.13.2...gson-parent-2.14.0
-
-
2.13.210 Sep 2025Release notes
Open source →The main changes in this release are just newer dependencies.
What's Changed
- Improved packaging of JPMS module declaration in Gson jar
This fixes an issue where Eclipse and VS Code users could not refer to the Gson module namecom.google.gson. See issue #2679. - Remove internal class
GsonPreconditionsby @Marcono1234 in #2879 - Switch to using central-publishing-maven-plugin by @eamonnmcmanus in #2900
New Contributors
- @MukjepScarlet made their first contribution in #2852
- @ChrisCraik made their first contribution in #2856
Full Changelog: gson-parent-2.13.1...gson-parent-2.13.2
- Improved packaging of JPMS module declaration in Gson jar
-
2.13.2-rc110 Sep 2025 pre-releaseNothing published for this version
-
2.13.124 Apr 2025Release notes
Open source →What's Changed
- Give FieldNamingStrategy the ability to return multiple String names by @mfriesen in #2776
- Remove outdated android-proguard-example by @Goooler in #2843
- Adjust Troubleshooting Guide ProGuard / R8 section by @Marcono1234 in #2844
- Update dependencies, including the problematic
com.google.errorprone:error_prone_annotations:2.37.0.
New Contributors
Full Changelog: gson-parent-2.13.0...gson-parent-2.13.1
-
2.13.011 Apr 2025Release notes
Open source →What's Changed
-
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 anArrayList<String>. Usually that would lead to an immediateClassCastException, 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.ImmutableListbecause Gson now really is trying to create an
ImmutableListthrough its constructor, but that isn't possible.
Either change the requested type (in theTypeToken) toList<String>, or register aTypeAdapterorJsonDeserializerforImmutableList. -
The internal classes
$Gson$Typesand$Gson$Preconditionshave 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
-
-
2.12.130 Jan 2025Release notes
Open source →The only difference between this release and 2.12.0 is that OSGi declarations in the Gson jar now specify that
com.google.errorprone.annotationsis an optional dependency, not a required one. If you do not use OSGi then there is no effective change. -
2.12.027 Jan 2025Release notes
Open source →What's Changed
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:
- Allow registering adapters for
JsonElementagain by @Marcono1234 in #2789 - Add nesting limit for
JsonReaderby @Marcono1234 in #2588 - Add
@CheckReturnValueto our packages. by @cpovirk in #2693 - Add NullSafeTypeAdapter to prevent TypeAdapter.nullSafe() from returning nested null-safe type adapters (#2729) by @lyubomyr-shaydariv in #2731
- Support Properties subclasses in GsonTypes.getMapKeyAndValueTypes by @panic08 in #2758
- Enforce rawType to be a Class in ParameterizedTypeImpl by @panic08 in #2759
- Remove
AccessControllerusage for enum adapter by @Marcono1234 in #2704 - Fix typeArguments array not being cloned when resolving ParameterizedType with changed owner by @TBlueF in #2706
- Remove duplicated declaration of required OSGi execution environment by @HannesWell in #2711
- Move bnd.bnd file configuration into 'bnd' element of bnd-maven-plugin by @HannesWell in #2712
- Move enum and
JsonElementadapter classes to separate class files by @Marcono1234 in #2727 - EnumTypeAdapter constructor optimization by @esaulpaugh in #2734
- OSGi / bnd: Remove the self-Import of gson.annotations by @chrisrueger in #2735
New Contributors
- @cpovirk made their first contribution in #2693
- @jabagawee made their first contribution in #2701
- @TBlueF made their first contribution in #2706
- @HannesWell made their first contribution in #2711
- @esaulpaugh made their first contribution in #2734
- @chrisrueger made their first contribution in #2735
- @panic08 made their first contribution in #2756
Full Changelog: gson-parent-2.11.0...gson-parent-2.12.0
- Allow registering adapters for
-
2.11.019 May 2024Release notes
Open source →Most important changes
- Added default ProGuard / R8 rules (@Marcono1234, #2397, #2420; @sgjesse, #2448; @sfreilich)
If you are using ProGuard or R8 (for example for Android projects) you might not need any special Gson configuration anymore if your classes have a no-args constructor and use@SerializedNamefor their fields. - On Android, Gson now requires API level 21 or newer
- Added new
StrictnessAPI (@marten-voorberg & fellow students, #2437)
Some of Gson's API is still lenient by default, but you can now use the newly added methodsGsonBuilder#setStrictness,JsonReader#setStrictnessandJsonWriter#setStrictnesswithStrictness.STRICTto override this behavior and to instead strictly adhere to the JSON specification when parsing. - New
FormattingStyleclass to allow configuring line breaks in JSON output (@mihnita, #2231)
Can be set usingGsonBuilder#setFormattingStyleandJsonWriter#setFormattingStyle. TypeTokencan no longer capture type variables by default (@Marcono1234, #2376)
This was previously a common source of issues. The newly thrown exception refers to a Troubleshooting Guide article which explains this in more detail and provides suggestions for updating affected code.- Added serialization support for anonymous and local classes with a custom adapter (@Marcono1234, #2498)
This affects for exampleListimplementations returned by libraries such as Guava which are implemented as anonymous class, which were previously serialized asnull. Anonymous and local classes without custom adapter will still be serialized asnull. - Added dependency on
com.google.errorprone:error_prone_annotations
Your project can use Maven or Gradle dependency exclusions to remove the transitive error_prone_annotations dependency from Gson. Or if you are manually maintaining dependencies as JARs in your project you can omit error_prone_annotations. And it should still work correctly.
But Gson itself does declare it as a required dependency, and if you don't perform any custom configuration, then Maven or Gradle will by default try to download and use it. - Many exception messages now refer to the Troubleshooting Guide (@Marcono1234, #2357)
Feedback regarding the Troubleshooting Guide is appreciated! - Officially documented that JVM languages other than Java might not be fully supported, see the README.
- Guarantee that
JsonElement#toStringproduces JSON output (@Marcono1234, #2659)
Other changes
Bug fixes
- Fixed incorrect
JsonPrimitive#equalsresults for largeBigIntegervalues (@MaicolAntali, #2311) - Fixed incorrect
JsonPrimitive#equalsresults for largeBigDecimalvalues (@MaicolAntali, #2364) - Fixed
JsonReaderthrowingNumberFormatExceptioninstead ofMalformedJsonExceptionfor malformed Unicode escape sequences (@MaicolAntali, #2337) - Fixed
TypeToken#getParameterizedreturning bogusParameterizedTypefor non-generic types (@Marcono1234, #2447) - Fixed Java Record adapter not working for GraalVM Native Image (@eamonnmcmanus, #2465)
- Fixed
JsonWriter#namenot throwing exception when no JSON object is currently being written (@shivam-sehgal, #2475; @Marcono1234, #2476) - Fixed
Gson#getDelegateAdapternot working properly for@JsonAdapter(@Marcono1234, #2435)
Note thatnullis now not allowed asskipPastvalue anymore, which was previously allowed but undocumented. - Fixed
GsonBuildernot rejecting type adapters forObjectandJsonElement, whose default adapters cannot be overridden (@sachinp97; #2479) - Fixed no limits being enforced when deserializing
BigDecimalandBigInteger(@Marcono1234, #2510)
The new limits prevent potential performance problems when user code uses the deserialized numbers. Gson itself was and is not affected by these performance problems. The limits should be high enough to not cause issues for most use cases, but feedback is appreciated. - Fixed
GsonBuilder#setDateFormatnot rejecting invalid date formats (@Carpe-Wang, #2538) - Fixed
GsonBuilder#setDateFormatnot rejecting invalid date styles (@Marcono1234, #2545) - Fixed
GsonBuilder#setDateFormatignoring partial DEFAULT style (@Marcono1234, #2556) - Fixed
TypeToken#isAssignableFromthrowingAssertionErrorin some cases (@Marcono1234, #2544) - Fixed date adapters not restoring time zone after parsing (@Carpe-Wang, #2549)
- Fixed
TypeToken#equalserroneously returningfalsefor equal generic type parameters in some cases (@d-william, #2599) - Fixed incorrect inherited URLs in
pom.xml(@Marcono1234, #2351)
Performance improvements
- Slightly reduce memory usage for reflection-based adapter (@sembseth, #2325; @Marcono1234, #2440)
- Improved parsing speed of
ToNumberPolicy#LONG_OR_DOUBLE(@ctasada, #2674)
Gson maintenance
- Changed many unit tests to use Truth instead of JUnit for assertions (@MaicolAntali, #2299, #2304)
- Configured Error Prone to automatically check for bugs when compiling (@MaicolAntali, #2308)
- Simplified expected exception handling in tests (@elevne, #2454)
- Added integration test for GraalVM Native Image (@Marcono1234, #2466)
- Formatted the code according to the Google Style Guide & configured Spotless (@MaicolAntali, #2531, #2537)
- Made Maven build reproducible (@Marcono1234, #2543)
- Removed internal
DateTypeAdapterclass to reduce code duplication (@Marcono1234, #2546) - Dependencies and plugins updated by Dependabot
GitHub repository
- Renamed default branch from
mastertomain - GitHub Discussions have been enabled
For questions, ideas, tips... - Added GitHub pull request template (@Marcono1234, #2326)
- Added check for Android API compatibility (@Marcono1234, #2431)
Other
- Added
@CanIgnoreReturnValueas appropriate to Gson methods (@eamonnmcmanus, #2369)
This is useful if you enable Error Prone'sCheckReturnValuein your project when compiling, however Gson itself does not enable this by default. - Various documentation and test improvements and typo fixes (@False-Mask; @avimathur009; @elevne; @0o001; @Codegass; @33nya)
Many thanks to @Marcono1234 for drafting these release notes.
- Added default ProGuard / R8 rules (@Marcono1234, #2397, #2420; @sgjesse, #2448; @sfreilich)
-
2.10.106 Jan 2023Release notes
Open source →This is technically a minor release rather than a patch release because there is one small API change: a new
JsonObject.isEmpty()method.What's Changed: User-Visible Changes
- Added JsonObject method isEmpty() by @dhoard in #2233
- Fix non-threadsafe creation of adapter for type with cyclic dependency by @Marcono1234 in #1832
- Remove EOFException special casing of JsonStreamParser.next() by @Marcono1234 in #2281
- Improve exception message for duplicate field names by @Marcono1234 in #2251
- Fix the javadoc of JsonDeserializer.deserialize() by @MaicolAntali in #2243
- Bump os-maven-plugin from 1.7.0 to 1.7.1 by @dependabot in #2235
- Bump jackson-databind from 2.13.4.2 to 2.14.0 by @dependabot in #2234
- Bump maven-release-plugin from 3.0.0-M6 to 3.0.0-M7 by @dependabot in #2232
- Bump japicmp-maven-plugin from 0.16.0 to 0.17.1 by @dependabot in #2238
- Bump jackson-databind from 2.14.0 to 2.14.1 by @dependabot in #2241
- Bump bnd-maven-plugin from 6.3.1 to 6.4.0 by @dependabot in #2245
Site Documentation and Maintenance Changes (these were already visible)
- Add troubleshooting guide by @Marcono1234 in #2285
- Replace custom user guide header anchors by @Marcono1234 in #2289
- Improve variable names in user guide by @Marcono1234 in #2290
- Add 2.10 changes to CHANGELOG; minor release follow-ups by @Marcono1234 in #2229
- Mention in CHANGELOG that GitHub Releases are used in the future by @Marcono1234 in #2230
- GitHub Workflows security hardening by @sashashura in #2274
Other Changes
- Making consistent prefixs in PerformanceTest by @CirQ in #1760
- Adjust version numbers and a test to conform to the SemVer spec. by @eamonnmcmanus in #2237
- Remove covered condition in JsonNull.equals() by @MaicolAntali in #2271
- Remove the
finalkeyword fromprivatemethod by @MaicolAntali in #2276 - Code cleanup by @MaicolAntali in #2282
- Unnecessary unboxing at JsonPrimitive.getAsBoolean() by @MaicolAntali in #2277
- Rewrite the
testParsingDatesFormattedWithSystemLocale(), Fix #2199 by @MaicolAntali in #2287 - Port tests from JUnit 3 to JUnit 4 by @MaicolAntali in #2294
New Contributors (thanks!)
- @CirQ made their first contribution in #1760
- @dhoard made their first contribution in #2233
- @MaicolAntali made their first contribution in #2243
- @sashashura made their first contribution in #2274
Full Changelog: gson-parent-2.10...gson-parent-2.10.1
-
2.1025 Oct 2022Release notes
Open source →Most important changes
-
Support for serializing and deserializing Java records, on Java ≥ 16. (#2201)
-
Add
JsonArray.asListandJsonObject.asMapview methods (#2225) -
Fix
TypeAdapterRuntimeTypeWrappernot detecting reflectiveTreeTypeAdapterandFutureTypeAdapter(#1787) -
Improve
JsonReader.skipValue()(#2062) -
Perform numeric conversion for primitive numeric type adapters (#2158)
-
Add
Gson.fromJson(..., TypeToken)overloads (#1700) -
Fix changes to
GsonBuilderaffecting existingGsoninstances (#1815) -
Make
JsonElementconversion methods more consistent and fix javadoc (#2178) -
Throw
UnsupportedOperationExceptionwhenJsonWriter.jsonValueis not supported (#1651) -
Disallow
JsonObjectEntry.setValue(null)(#2167) -
Fix
TypeAdapter.toJsonthrowing AssertionError for custom IOException (#2172) -
Convert null to JsonNull for
JsonArray.set(#2170) -
Fixed nullSafe usage. (#1555)
-
Validate
TypeToken.getParameterizedarguments (#2166) -
Fix #1702: Gson.toJson creates CharSequence which does not implement toString (#1703)
-
Prefer existing adapter for concurrent
Gson.getAdaptercalls (#2153) -
Improve
ArrayTypeAdapterforObject[](#1716) -
Improve
AppendableWriterperformance (#1706)
List of all changes
- Improve AppendableWriter performance by @Marcono1234 in #1706
- Improve ArrayTypeAdapter for Object[] by @Marcono1234 in #1716
- Prefer existing adapter for concurrent
Gson.getAdaptercalls by @Marcono1234 in #2153 - Fix #1702: Gson.toJson creates CharSequence which does not implement toString by @Marcono1234 in #1703
- Deprecate JsonElement constructor by @Marcono1234 in #1761
- Validate
TypeToken.getParameterizedarguments by @Marcono1234 in #2166 - Fixed nullSafe usage. by @bufistov in #1555
- Convert null to JsonNull for
JsonArray.setby @Marcono1234 in #2170 - Clarify that
GsonBuilder.setExclusionStrategiesdoes not replace existing ones by @Marcono1234 in #2168 - Fix typo by @JamesZBL in #1246
- Remove not needed .gitattributes file by @Marcono1234 in #1862
- Improve InternationalizationTest by @Marcono1234 in #1705
- Fix JsonWriter documentation regarding top-level value by @Marcono1234 in #1766
- Fix JsonTreeReader throwing wrong exception type for non-finite doubles by @Marcono1234 in #1782
- Clarify doc about non-finite numbers for non-lenient JsonReader by @Marcono1234 in #1723
- Fix
TypeAdapter.toJsonthrowing AssertionError for custom IOException by @Marcono1234 in #2172 - Add test for JsonArray.isEmpty() by @LorenzNickel in #2173
- Disallow
JsonObjectEntry.setValue(null)by @Marcono1234 in #2167 - Improve GsonTest.testGetAdapter_Concurrency by @Marcono1234 in #2177
- Add null checks for GsonBuilder methods by @Marcono1234 in #2179
- Throw UnsupportedOperationException when JsonWriter.jsonValue is not supported by @Marcono1234 in #1651
- Make JsonElement conversion methods more consistent and fix javadoc by @Marcono1234 in #2178
- Bump maven-javadoc-plugin from 3.4.0 to 3.4.1 by @dependabot in #2175
- Add tests checking GsonBuilder not affecting existing Gson instances by @Marcono1234 in #1815
- Fix #1697: Mention that GsonBuilder.registerTypeAdapter makes (de-)serializers null-safe by @Marcono1234 in #1704
- Replace
$Gson$Preconditions.checkNotNullwithObjects.requireNonNullby @Marcono1234 in #2180 - Verify that JsonTreeReader and JsonTreeWriter override all methods by @Marcono1234 in #2181
- Fail Maven build on compiler warnings; remove some warning suppressions by @Marcono1234 in #2183
- Add GitHub workflow for checking API compatibility by @Marcono1234 in #2182
- Bump japicmp-maven-plugin from 0.15.7 to 0.16.0 by @dependabot in #2187
- Bump jackson-databind from 2.13.3 to 2.13.4 by @dependabot in #2191
- Remove usage of oss-parent Maven parent and update
ReleaseProcess.mdby @Marcono1234 in #2159 - Improve documentation by @Marcono1234 in #2193
- updated JsonDeserializer example by @deeptimarrivada1 in #2192
- Add Gson.fromJson(..., TypeToken) overloads by @Marcono1234 in #1700
- Bump maven-jar-plugin from 3.2.2 to 3.3.0 by @dependabot in #2195
- Build on JDK 17 as well as 11. by @eamonnmcmanus in #2198
- Fix incorrect HTML headings in Javadoc by @Marcono1234 in #2200
- Add a currently-failing test for Java records and
@Ignoreit. by @eamonnmcmanus in #2203 - Follow-up for record test build changes by @Marcono1234 in #2207
- Disable Maven transfer progress for GitHub workflows by @Marcono1234 in #2206
- Only create one UnsafeAllocator instance by @kb-1000 in #2196
- Mention in User Guide alternative for Gson versions without fromJson(..., TypeToken) by @Marcono1234 in #2209
- Fix typo in GsonBuilder Javadoc by @BillyGalbreath in #2213
- Add Javadoc
@sincetags for previously added elements by @Marcono1234 in #2211 - Improve versioning support documentation and validate version by @Marcono1234 in #2214
- Perform numeric conversion for primitive numeric type adapters by @Marcono1234 in #2158
- Clarify in documentation that Gson might cache strategy results by @Marcono1234 in #2215
- Improve
JsonReader.skipValue()by @Marcono1234 in #2062 - Fix TypeAdapterRuntimeTypeWrapper not detecting reflective TreeTypeAdapter and FutureTypeAdapter by @Marcono1234 in #1787
- Support Java Records when present in JVM. by @staale in #2201
- Small adjustments to the new record code. by @eamonnmcmanus in #2219
- Bump jackson-databind from 2.13.4 to 2.13.4.1 by @dependabot in #2222
- Bump jackson-databind from 2.13.4.1 to 2.13.4.2 by @dependabot in #2223
- Add
JsonArray.asListandJsonObject.asMapview methods by @Marcono1234 in #2225 - Adjust Record adapter and extend test coverage by @Marcono1234 in #2224
- Small tweaks to fix Error Prone warnings. by @eamonnmcmanus in #2227
- Automatically replace version references on
release:prepareby @Marcono1234 in #2212 - Revise the version regex in
GsonVersionDiagnosticsTest. by @eamonnmcmanus in #2228
New Contributors
- @bufistov made their first contribution in #1555
- @JamesZBL made their first contribution in #1246
- @xtay2 made their first contribution in #2169
- @deeptimarrivada1 made their first contribution in #2192
- @kb-1000 made their first contribution in #2196
- @BillyGalbreath made their first contribution in #2213
- @staale made their first contribution in #2201
Full Changelog: gson-parent-2.9.1...gson-parent-2.10
Release notes
Open source →- Support for serializing and deserializing Java records, on Java ≥ 16. (https://github.com/google/gson/pull/2201)
- Add
JsonArray.asListandJsonObject.asMapview methods (https://github.com/google/gson/pull/2225) - Fix
TypeAdapterRuntimeTypeWrappernot detecting reflectiveTreeTypeAdapterandFutureTypeAdapter(https://github.com/google/gson/pull/1787) - Improve
JsonReader.skipValue()(https://github.com/google/gson/pull/2062) - Perform numeric conversion for primitive numeric type adapters (https://github.com/google/gson/pull/2158)
- Add
Gson.fromJson(..., TypeToken)overloads (https://github.com/google/gson/pull/1700) - Fix changes to
GsonBuilderaffecting existingGsoninstances (https://github.com/google/gson/pull/1815) - Make
JsonElementconversion methods more consistent and fix javadoc (https://github.com/google/gson/pull/2178) - Throw
UnsupportedOperationExceptionwhenJsonWriter.jsonValueis not supported (https://github.com/google/gson/pull/1651) - Disallow
JsonObjectEntry.setValue(null)(https://github.com/google/gson/pull/2167) - Fix
TypeAdapter.toJsonthrowing AssertionError for custom IOException (https://github.com/google/gson/pull/2172) - Convert null to JsonNull for
JsonArray.set(https://github.com/google/gson/pull/2170) - Fixed nullSafe usage. (https://github.com/google/gson/pull/1555)
- Validate
TypeToken.getParameterizedarguments (https://github.com/google/gson/pull/2166) - Fix #1702: Gson.toJson creates CharSequence which does not implement toString (https://github.com/google/gson/pull/1703)
- Prefer existing adapter for concurrent
Gson.getAdaptercalls (https://github.com/google/gson/pull/2153) - Improve
ArrayTypeAdapterforObject[](https://github.com/google/gson/pull/1716) - Improve
AppendableWriterperformance (https://github.com/google/gson/pull/1706)
-
-
2.9.131 Jul 2022Release notes
Open source →- Make
ObjectandJsonElementdeserialization iterative rather than recursive (https://github.com/google/gson/pull/1912) - Added parsing support for enum that has overridden toString() method (https://github.com/google/gson/pull/1950)
- Removed support for building Gson with Gradle (https://github.com/google/gson/pull/2081)
- Removed obsolete
codegenhierarchy (https://github.com/google/gson/pull/2099) - Add support for reflection access filter (https://github.com/google/gson/pull/1905)
- Improve
TypeTokencreation validation (https://github.com/google/gson/pull/2072) - Add explicit support for
floatinJsonWriter(https://github.com/google/gson/pull/2130, https://github.com/google/gson/pull/2132) - Fail when parsing invalid local date (https://github.com/google/gson/pull/2134)
Also many small improvements to javadoc.
- Make
-
2.9.011 Feb 2022Release notes
Open source →The minimum supported Java version changes from 6 to 7.
- Change target Java version to 7 (https://github.com/google/gson/pull/2043)
- Put
module-info.classinto Multi-Release JAR folder (https://github.com/google/gson/pull/2013) - Improve error message when abstract class cannot be constructed (https://github.com/google/gson/pull/1814)
- Support EnumMap deserialization (https://github.com/google/gson/pull/2071)
- Add LazilyParsedNumber default adapter (https://github.com/google/gson/pull/2060)
- Fix JsonReader.hasNext() returning true at end of document (https://github.com/google/gson/pull/2061)
- Remove Gradle build support. Build script was outdated and not actively maintained anymore (https://github.com/google/gson/pull/2063)
- Add
GsonBuilder.disableJdkUnsafe()(https://github.com/google/gson/pull/1904) - Add
UPPER_CASE_WITH_UNDERSCORESin FieldNamingPolicy (https://github.com/google/gson/pull/2024) - Fix failing to serialize Collection or Map with inaccessible constructor (https://github.com/google/gson/pull/1902)
- Improve TreeTypeAdapter thread-safety (https://github.com/google/gson/pull/1976)
- Fix
Gson.newJsonWriterignoring lenient and HTML-safe setting (https://github.com/google/gson/pull/1989) - Delete unused LinkedHashTreeMap (https://github.com/google/gson/pull/1992)
- Make default adapters stricter; improve exception messages (https://github.com/google/gson/pull/2000)
- Fix
FieldNamingPolicy.upperCaseFirstLetteruppercasing non-letter (https://github.com/google/gson/pull/2004)
-
2.8.929 Oct 2021Release notes
Open source →- Make OSGi bundle's dependency on
sun.miscoptional (https://github.com/google/gson/pull/1993). - Deprecate
Gson.excluder()exposing internalExcluderclass (https://github.com/google/gson/pull/1986). - Prevent Java deserialization of internal classes (https://github.com/google/gson/pull/1991).
- Improve number strategy implementation (https://github.com/google/gson/pull/1987).
- Fix LongSerializationPolicy null handling being inconsistent with Gson (https://github.com/google/gson/pull/1990).
- Support arbitrary Number implementation for Object and Number deserialization (https://github.com/google/gson/pull/1290).
- Bump proguard-maven-plugin from 2.4.0 to 2.5.1 (https://github.com/google/gson/pull/1980).
- Don't exclude static local classes (https://github.com/google/gson/pull/1969).
- Fix
RuntimeTypeAdapterFactorydepending on internalStreamsclass (https://github.com/google/gson/pull/1959). - Improve Maven build (https://github.com/google/gson/pull/1964).
- Make dependency on
java.sqloptional (https://github.com/google/gson/pull/1707).
- Make OSGi bundle's dependency on
-
2.8.820 Aug 2021Release notes
Open source →- Fixed issue with recursive types (https://github.com/google/gson/issues/1390).
- Better behavior with Java 9+ and
Unsafeif there is a security manager (https://github.com/google/gson/pull/1712). EnumTypeAdapternow works better when ProGuard has obfuscated enum fields (https://github.com/google/gson/pull/1495).
-
2.8.724 May 2021Release notes
Open source →- Fixed
ISO8601UtilsTestfailing on systems with UTC+X. - Improved javadoc for
JsonStreamParser. - Updated proguard.cfg (https://github.com/google/gson/pull/1693).
- Fixed
IllegalStateExceptioninJsonTreeWriter(https://github.com/google/gson/issues/1592). - Added
JsonArray.isEmpty()(https://github.com/google/gson/pull/1640). - Added new test cases (https://github.com/google/gson/pull/1638).
- Fixed OSGi metadata generation to work on JavaSE < 9 (https://github.com/google/gson/pull/1603).
- Fixed
-
2.8.604 Oct 2019Release notes
Open source →2019-10-04 GitHub Diff
- Added static methods
JsonParser.parseStringandJsonParser.parseReaderand deprecated instance methodJsonParser.parse - Java 9 module-info support
- Added static methods
-
2.8.522 May 2018Release notes
Open source →2018-05-21 GitHub Diff
- Print Gson version while throwing AssertionError and IllegalArgumentException
- Moved
utils.VersionUtilsclass tointernal.JavaVersion. This is a potential backward incompatible change from 2.8.4 - Fixed issue https://github.com/google/gson/issues/1310 by supporting Debian Java 9
-
2.8.401 May 2018Release notes
Open source →2018-05-01 GitHub Diff
- Added a new FieldNamingPolicy,
LOWER_CASE_WITH_DOTSthat maps JSON namesomeFieldNametosome.field.name - Fixed issue https://github.com/google/gson/issues/1305 by removing compile/runtime dependency on
sun.misc.Unsafe
- Added a new FieldNamingPolicy,
-
2.8.327 Apr 2018Release notes
Open source →2018-04-27 GitHub Diff
- Added a new API,
GsonBuilder.newBuilder()that clones the current builder - Preserving DateFormatter behavior on JDK 9
- Numerous other bugfixes
- Added a new API,
-
2.8.220 Sep 2017Release notes
Open source →2017-09-19 GitHub Diff
- Introduced a new API,
JsonElement.deepCopy() - Numerous other bugfixes
- Introduced a new API,
-
2.8.131 May 2017Release notes
Open source →2017-05-30 GitHub Diff
- New:
JsonObject.keySet() @JsonAdapterannotation can now useJsonSerializerandJsonDeserializeras well.
- New:
-
2.8.027 Oct 2016Nothing published for this version
-
2.714 Jun 2016Release notes
Open source →2016-06-14 GitHub Diff
- Added support for JsonSerializer/JsonDeserializer in @JsonAdapter annotation
- Exposing Gson properties excluder(), fieldNamingStrategy(), serializeNulls(), htmlSafe()
- Added JsonObject.size() method
- Added JsonWriter.value(Boolean value) method
- Using ArrayDeque, ConcurrentHashMap, and other JDK 1.6 features
- Better error reporting
- Plenty of other bug fixes
-
2.6.227 Feb 2016Release notes
Open source →2016-02-26 GitHub Diff
- Fixed an NPE bug with @JsonAdapter annotation
- Added back OSGI manifest
- Some documentation typo fixes
-
2.6.112 Feb 2016Release notes
Open source →2016-02-11 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.
-
2.611 Feb 2016Release notes
Open source →2016-02-11 GitHub Diff
- Permit timezones without minutes in the default date adapter.
- Update reader and writer for RFC 7159. This means that strings, numbers, booleans and null may be top-level values in JSON documents, even if the reader is strict.
- New
setLenient()method onGsonBuilder. This setting impacts the new factory methodGson.newJsonReader(). - Adapters discovered with
@JsonAdapterare now null safe by default.
-
2.524 Nov 2015Release notes
Open source →2015-11-24 GitHub Diff
- Updated minimum JDK version to 1.6
- Improved Date Deserialization by accepting many date formats
- Added support for
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. - Improved debugging information when some exceptions are thrown
-
2.404 Oct 2015Release notes
Open source →2015-10-04
- Drop
IOExceptionfromTypeAdapter.toJson(). This is a binary-compatible change, but may cause compiler errors whereIOExceptionsare being caught but no longer thrown. The correct fix for this problem is to remove the unnecessarycatchclause. - New:
Gson.newJsonWritermethod returns configuredJsonWriterinstances. - New:
@SerializedNamenow works with [AutoValue’s][autovalue] abstract property methods. - New:
@SerializedNamepermits alternate names when deserializing. - New:
JsonWriter#jsonValuewrites raw JSON values. - New: APIs to add primitives directly to
JsonArrayinstances. - New: ISO 8601 date type adapter. Find this in extras.
- Fix:
FieldNamingPolicynow works properly when running on a device with a Turkish locale. [autovalue]: https://github.com/google/auto/tree/main/value
- Drop
-
2.3.120 Nov 2014Release notes
Open source →2014-11-20
- Added support to serialize objects with self-referential fields. The self-referential field is set to null in JSON. Previous version of Gson threw a StackOverflowException on encountering any self-referential fields.
- The most visible impact of this is that Gson can now serialize Throwable (Exception and Error)
- Added support for @JsonAdapter annotation on enums which are user defined types
- Fixed bug in getPath() with array of objects and arrays of arrays
- Other smaller bug fixes
- Added support to serialize objects with self-referential fields. The self-referential field is set to null in JSON. Previous version of Gson threw a StackOverflowException on encountering any self-referential fields.
-
2.311 Aug 2014Release notes
Open source →2014-08-11
- The new @JsonAdapter annotation to specify a Json TypeAdapter for a class field
- JsonPath support: JsonReader.getPath() method returns the JsonPath expression
- New public methods in JsonArray (similar to the java.util.List):
contains(JsonElement), remove(JsonElement), remove(int index), set(int index, JsonElement element) - Many other smaller bug fixes
-
2.2.413 May 2013Release notes
Open source →2013-05-13
- Fix internal map (LinkedHashTreeMap) hashing bug.
- Bug fix (Issue 511)
-
2.2.312 Apr 2013 -
2.2.203 Jul 2012Release notes
Open source →2012-07-02
- 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 prohibited started Gson 2.0. We decided to allow it again: This enables a user to parse 1/0 as boolean values for compatibility with iOS JSON libraries.
- (Incompatible behavior change in
JsonParser): In the past, ifJsonParserencountered a stream that terminated prematurely, it returnedJsonNull. This behavior wasn't correct because the stream had invalid JSON, not a null.JsonParseris now changed to throwJsonSyntaxExceptionin this case. Note that if JsonParser (or Gson) encounter an empty stream, they still returnJsonNull.
-
2.2.111 May 2012 -
2.206 May 2012Release notes
Open source →2012-05-05
- Added getDelegateAdapter in Gson class
- Fixed a security bug related to denial of service attack with Java HashMap String collisions.
-
2.131 Dec 2011Release notes
Open source →2011-12-30 (Targeted Dec 31, 2011)
- Support for user-defined streaming type adapters
- continued performance enhancements
- Dropped support for type hierarchy instance creators. We don't expect this to be a problem. We'll also detect fewer errors where multiple type adapters can serialize the same type. With APIs like getNextTypeAdapter, this might actually be an improvement!
-
2.013 Nov 2011Release notes
Open source →2011-11-13
Faster
- Previous versions first parsed complete document into a DOM-style model (JsonObject or JsonArray) and then bound data against that. Gson 2 does data binding directly from the stream parser.
More Predictable
- Objects are serialized and deserialized in the same way, regardless of where they occur in the object graph.
Changes to watch out for
-
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
Other changes to be aware of
- Gson 2.0 doesn’t support type adapters for primitive types.
- Gson 1.7 uses arbitrary precision for primitive type conversion (so -122.08e-2132 != 0). Gson 2.0 uses double precision (so -122.08e-2132 == 0).
- Gson 1.7 sets subclass fields when an InstanceCreator returns a subclass when the value is a field of another object. Gson 2.0 sets fields of the requested type only.
- Gson 1.7 versioning never skips the top-level object. Gson 2.0 versioning applies to all objects.
- Gson 1.7 truncates oversized large integers. Gson 2.0 fails on them.
- Gson 2.0 permits integers to have .0 fractions like "1.0".
- Gson 1.7 throws IllegalStateException on circular references. Gson 2.0 lets the runtime throw a StackOverflowError.
-
1.7.230 Sep 2011Release notes
Open source →2011-09-30 (Unplanned release)
- Fixed a threading issue in FieldAttributes (Issue 354)
-
1.7.113 Apr 2011Release notes
Open source →2011-04-13 (Unplanned release)
- Fixed Gson jars in Maven Central repository
- Removed assembly-descriptor.xml and maven pom.xml/pom.properties files from Gson binary jar. This also ensures that jarjar can be run correctly on Gson.
-
1.712 Apr 2011Release notes
Open source →2011-04-12 (Targeted: Jan 2011)
- No need to define no-args constructors for classes serialized with Gson
- Ability to register a hierarchical type adapter
- Support for serialization and deserialization of maps with complex keys
- Serialization and deserialization specific exclusion strategies
- Allow concrete data structure fields without type adapters
- Fixes "type" management (i.e. Wildcards, etc.)
- Major performance enhancements by reducing the need for Java reflection See detailed announcement at this thread in the Gson Google Group.
-
1.615 Mar 2011Release notes
Open source →2010-11-24 (Targeted: Oct, 2010)
- New stream parser APIs
- New parser that improves parsing performance significantly
-
1.514 Mar 2011Release notes
Open source →2010-08-19 (Target Date: Aug 18, 2010)
- Added
UPPER_CAMEL_CASE_WITH_SPACESnaming policy - Added SQL date and time support
- A number of performance improvements: Using caching of field annotations for speeding up reflection, replacing recursive calls in the parser with a for loop.
- Added
-
1.409 Oct 2009Release notes
Open source →2009_10_09
- JsonStreamParser: A streaming parser API class to deserialize multiple JSON objects on a stream (such as a pipelined HTTP response)
- Raised the deserialization limit for byte and object arrays and collection to over 11MB from 80KB. See issue 96.
- While serializing, Gson now uses the actual type of a field. This allows serialization of base-class references holding sub-classes to the JSON for the sub-class. It also allows serialization of raw collections. See Issue 155, 156.
- Added a
Gson.toJsonTree()method that serializes a Java object to a tree of JsonElements. See issue 110. - Added a
Gson.fromJson(JsonElement)method that deserializes from a Json parse tree. - Updated
Exposeannotation to contain parameters serialize and deserialize to control whether a field gets serialized or deserialized. See issue 146. - Added a new naming policy
LOWER_CASE_WITH_DASHES - Default date type adapter is now thread-safe. See Issue 162.
JsonElement.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.- Fixed bugs in pretty printing. See issue 153.
- If a field causes circular reference error, Gson lists the field name instead of the object value. See issue 118.
- Gson now serializes a list with null elements correctly. See issue 117.
- Fixed issue 121, 123, 126.
- Support user defined exclusion strategies (Feature Request 138).
-
1.110 Aug 2008Release notes
Open source →2008-07-01 (Target Date Thursday, July 3, 2008)
- Includes fixes for Issue 9, Issue 16, Issue 18