bb7f0b6bb0
Add setSerializeNulls() to JsonWriter, so nulls can be skipped from serialization. This does not yet impact JsonElementWriter. One change in behavior: if the only value is skipped, we now emit "null" rather than "".
69 lines
3.7 KiB
Plaintext
69 lines
3.7 KiB
Plaintext
What's new in GSON 2.0
|
|
|
|
GSON 1.x used to automatically unwrap single-element arrays as necessary.
|
|
GSON 2.x doesn't.
|
|
com.google.gson.functional.ArrayTest.testSingleStringArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest#testPrimitiveIntegerAutoboxedInASingleElementArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest#testPrimitiveLongAutoboxedInASingleElementArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest#testPrimitiveBooleanAutoboxedDeserialization
|
|
com.google.gson.functional.PrimitiveTest.testPrimitiveBooleanAutoboxedInASingleElementArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest.testPrimitiveDoubleAutoboxedInASingleElementArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest.testBigDecimalInASingleElementArrayDeserialization
|
|
com.google.gson.functional.PrimitiveTest.testBigIntegerInASingleElementArrayDeserialization
|
|
com.google.gson.functional.StringTest.testStringValueAsSingleElementArrayDeserialization
|
|
com.google.gson.functional.EnumTest.testTopLevelEnumInASingleElementArrayDeserialization
|
|
|
|
GSON 1.x permitted primitive types to be overridden
|
|
GSON 2.x doesn't.
|
|
com.google.gson.functional.ArrayTest.testArrayOfPrimitivesWithCustomTypeAdapter
|
|
com.google.gson.functional.PrimitiveTest.testOverridingDefaultPrimitiveSerialization
|
|
|
|
|
|
GSON 1.x rejects integers that have any fraction, even if it is ".0"
|
|
GSON 2.x permits integers to have ".0" fractions like "1.0"
|
|
com.google.gson.functional.PrimitiveTest.testDeserializingDecimalPointValuesAsIntegerFails
|
|
|
|
GSON 1.x truncates oversized large integers and longs
|
|
GSON 2.x fails on oversized large integers and longs
|
|
com.google.gson.functional.PrimitiveTest.testDeserializingBigIntegerAsInteger
|
|
com.google.gson.functional.PrimitiveTest.testDeserializingBigIntegerAsLong
|
|
|
|
|
|
GSON 1.x uses arbitrary precision for primitive type conversion (so -122.08e-2132 != 0)
|
|
GSON 2.x uses double precision (so -122.08e-2132 == 0)
|
|
com.google.gson.functional.PrimitiveTest.testDeserializingBigDecimalAsLongFails
|
|
|
|
|
|
GSON 1.x supports type adapters for primitive types
|
|
GSON 2.x doesn't
|
|
com.google.gson.functional.CustomTypeAdaptersTest.testCustomSerializerForLong
|
|
com.google.gson.functional.CustomTypeAdaptersTest.testCustomDeserializerForLong
|
|
|
|
|
|
GSON 1.x throws IllegalStateException on circular references
|
|
GSON 2.x lets the runtime throw a StackOverflowError
|
|
com.google.gson.functional.CircularReferenceTest.testCircularSerialization
|
|
com.google.gson.functional.CircularReferenceTest.testSelfReferenceSerialization
|
|
com.google.gson.functional.CircularReferenceTest.testSelfReferenceArrayFieldSerialization
|
|
com.google.gson.functional.CircularReferenceTest.testSelfReferenceCustomHandlerSerialization
|
|
|
|
|
|
GSON 1.x sometimes sets subclass fields when an InstanceCreator returns a subclass.
|
|
This occurs only when the value is a field of another object: not when its
|
|
the top level object or a collection element.
|
|
GSON 2.x sets fields of the requested type only
|
|
com.google.gson.functional.InstanceCreatorTest.testInstanceCreatorReturnsSubTypeForField
|
|
|
|
|
|
GSON 1.x applies different rules for versioning for classes vs fields. So, if you deserialize a
|
|
JSON into a field that is supposed to be skipped, the field is set to null (or default value).
|
|
However, if you deserialize it to a top-level class, a default instance is returned.
|
|
GSON 2.x returns null for the top-level class.
|
|
com.google.gson.functional.VersioningTest.testIgnoreLaterVersionClassDeserialization
|
|
|
|
|
|
GSON 1.x creates the empty string "" if the only element is skipped
|
|
GSON 2.x writes "null" if the only element is skipped
|
|
com.google.gson.functional.ObjectTest.testAnonymousLocalClassesSerialization
|
|
com.google.gson.functional.FieldExclusionTest.testInnerClassExclusion
|
|
com.google.gson.functional.VersioningTest.testIgnoreLaterVersionClassSerialization |