The change log for versions newer than 2.10 is available only on the GitHub Releases page.
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)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.
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)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).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).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).2019-10-04 GitHub Diff
JsonParser.parseString
and JsonParser.parseReader
and deprecated instance method JsonParser.parse
2018-05-21 GitHub Diff
utils.VersionUtils
class to internal.JavaVersion
. This is a potential backward incompatible change from 2.8.42018-05-01 GitHub Diff
LOWER_CASE_WITH_DOTS
that mapps JSON name someFieldName
to some.field.name
sun.misc.Unsafe
2018-04-27 GitHub Diff
GsonBuilder.newBuilder()
that clones the current builder2017-09-19 GitHub Diff
JsonElement.deepCopy()
2017-05-30 GitHub Diff
JsonObject.keySet()
@JsonAdapter
annotation can now use JsonSerializer
and JsonDeserializer
as well.2016-10-26 GitHub Diff
TypeToken.getParameterized()
and TypeToken.getArray()
make it easier to register or look up a TypeAdapter
.@JsonAdapter(nullSafe=true)
to specify that a custom type adapter handles null.2016-06-14 GitHub Diff
2016-02-26 GitHub Diff
2016-02-11 GitHub Diff
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.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.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/master/value2014-11-20
2014-08-11
contains(JsonElement), remove(JsonElement), remove(int index), set(int index, JsonElement element)
2013-05-13
2013-04-12
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
2012-05-05
2011-12-30 (Targeted Dec 31, 2011)
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-04-13 (Unplanned release)
2011-04-12 (Targeted: Jan 2011)
2010-11-24 (Targeted: Oct, 2010)
2010-08-19 (Target Date: Aug 18, 2010)
UPPER_CAMEL_CASE_WITH_SPACES
naming policy2009_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_DASHES
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.2009-04-01
<data>
element.2009-03-17
FieldNamingStrategy
public and allowing FieldNamingStrategy
to be set in GsonBuilder. See issue 104.generateNonExecutableJson()
that prefixes the generated JSON with some text to make the output non-executable Javascript. Gson now recognizes this text from input while deserializing and filters it out. This feature is meant to prevent script sourcing attacks. See Issue 42.2009-02-05
2009_01 (Target Date Friday, Dec 15, 2008)
Made JSON parser lenient by allowing unquoted member names while parsing. See Issue 41
Better precision handling for floating points. See Issue 71, 72
Support for deserialization of special double values: NaN, infinity and negative infinity. See Issue 81
Backward compatibility issue found with serialization of Collection<Object>
type. See Issue 73 and 83.
Able to serialize null keys and/or values within a Map. See Issue 77
Deserializing non-String value keys for Maps. See Issue 85.
Support for clashing field name. See Issue 76.
Removed the need to invoke instance creator if a deserializer is registered. See issues 37 and 69.
Added default support for java.util.UUID. See Issue 79
Changed Gson.toJson()
methods to use Appendable
instead of Writer
. Issue 52. This requires that clients recompile their source code that uses Gson.
2008-11-15 (Target Date Friday, Oct 31, 2008)
2008-10-14 (Target Date: None, Unplanned)
2008-10-13 (Target Date Friday, Oct 7, 2008)
Note: This release was abandoned since it caused a regression (Issue 58) bug.
2008-08-29 (Target Date Tuesday Aug 26, 2008)
2008-07-18 (Target Date Friday, Aug 1, 2008)
2008-07-01 (Target Date Thursday, July 3, 2008)
2008-06-17 (Target Date Friday, Jun 13, 2008)