All Versions
Latest Version
Avg Release Cycle
133 days
Latest Release
355 days ago

Changelog History
Page 3

  • v2.1

    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!
  • v2.0



    • 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.
  • v1.7.2

    2011-09-30 (Unplanned release)

    • Fixed a threading issue in FieldAttributes (Issue 354)
  • v1.7.1

    2011-04-13 (Unplanned release)

    • Fixed Gson jars in Maven Central repository
    • Removed assembly-descriptor.xml and maven pom.xml/ files from Gson binary jar. This also ensures that jarjar can be run correctly on Gson.
  • v1.7

    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.
  • v1.6

    2010-11-24 (Targeted: Oct, 2010)

    • New stream parser APIs
    • New parser that improves parsing performance significantly
  • v1.5

    2010-08-19 (Target Date: Aug 18, 2010)

    • Added UPPER_CAMEL_CASE_WITH_SPACES naming 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.
  • v1.4


    • 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 Expose annotation 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).
  • v1.3

    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.

  • v1.2.3

    2008-11-15 (Target Date Friday, Oct 31, 2008)

    • Added support to serialize raw maps. See issue 45
    • Made Gson thread-safe by fixing Issue 63
    • Fixed Issue 68 to allow default type adapters for primitive types to be replaced by custom type adapters.
    • Relaxed the JSON parser to accept escaped slash (\/) as a valid character in the string. See Issue 66