Jesse Wilson
01661426f9
Fix broken example.
...
Fixes bug 360.
2011-10-01 04:09:38 +00:00
Jesse Wilson
de727d8c48
Delete dead code found by coverage
2011-10-01 02:04:48 +00:00
Jesse Wilson
38ce53766e
More consistency on serializeNulls: we never emit the empty string for top-level objects.
2011-10-01 01:10:11 +00:00
Jesse Wilson
de835d4dcd
Roll back JsonSerializationContext and JsonDeserializationContext to their 1.7.2 API.
2011-10-01 00:58:25 +00:00
Jesse Wilson
70abd0ba87
Finishing touches on JsonElementWriter
2011-10-01 00:42:28 +00:00
Jesse Wilson
349c01e861
JsonElementWriter NaN, -Infinity, Infinity
2011-10-01 00:35:51 +00:00
Jesse Wilson
ed2b25ddef
Don't serialize nulls in JsonElementWriter if setSerializeNulls(false)
2011-10-01 00:22:33 +00:00
Jesse Wilson
9b7b49bf0f
Implement JsonElementWriter.close()
2011-10-01 00:12:36 +00:00
Inderjeet Singh
9623e3bead
Updated Gson version to 2.0-SNAPSHOT
2011-09-30 18:16:16 +00:00
Inderjeet Singh
d3f927eb42
Pure refactorings:
...
Replaced DEFAULT_SERIALIZERS, DEFAULT_DESERIALIZERS and DEFAULT_INSTANCE_CREATORS with a single EMPTY_MAP.
Removed obsoleted TODO from Gson.
made ParameterizedTypeHandlerMap.makeUnmodifiable a builder method that returns this instance.
2011-09-30 17:56:40 +00:00
Inderjeet Singh
1621011bf2
Deleted unused CircularReferenceException
2011-09-30 17:39:46 +00:00
Inderjeet Singh
1470f20fc0
Removed unused field
2011-09-30 17:11:44 +00:00
Inderjeet Singh
47a36fd095
Fixed Eclipse warnings
2011-09-30 17:08:35 +00:00
Jesse Wilson
cf15565243
Don't round trip through strings
2011-09-30 07:24:07 +00:00
Jesse Wilson
bb7f0b6bb0
Adopt JsonElementWriter in GSON.
...
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 "".
2011-09-30 07:08:44 +00:00
Jesse Wilson
364de80611
Stream to a DOM
2011-09-30 06:32:33 +00:00
Jesse Wilson
d26c818918
New streaming writer writes to DOMs
2011-09-30 06:26:46 +00:00
Jesse Wilson
6c0566bd22
Start using JsonElementReader in TypeAdapter.
...
Also fix strict handling of NaN and Infinity
2011-09-30 03:47:30 +00:00
Jesse Wilson
1bb01055f0
Tests for JsonElementReader.close
2011-09-30 03:31:44 +00:00
Jesse Wilson
9ce9c62b44
Tests for JsonElementReader
2011-09-30 03:25:41 +00:00
Jesse Wilson
bd2a0ac466
Support JsonReader API on DOM objects.
...
This still needs test coverage & documentation but it appears to work!
2011-09-30 00:44:37 +00:00
Inderjeet Singh
423d18feb5
Revised test to take into account known problems with JsonElement that holds BigInteger values.
2011-09-29 22:18:16 +00:00
Inderjeet Singh
2541e658f7
Fixed com.google.gson.functional.VersioningTest.testIgnoreLaterVersionClassDeserialization by changing Gson behavior incompatibly (but more consistent).
...
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.
2011-09-29 22:15:37 +00:00
Jesse Wilson
8b21c7770b
Use the same behavior in all situations when an InstanceCreator returns a subclass.
...
Previously we would set the field if the created instance is being assigned to a field of another object. We wouldn't set it when the created instance is a collection element or the top-level object.
2011-09-29 16:38:24 +00:00
Jesse Wilson
4d0775ce8e
Let the runtime throw on circular references
2011-09-28 19:38:43 +00:00
Jesse Wilson
46e65a77c5
Convert RuntimeTypeAdapter to a TypeAdapterFactory; this avoids the need for serializeDefault()
2011-09-28 19:14:46 +00:00
Jesse Wilson
2236c95c37
Death to serializeDefault and deserializeDefault
2011-09-28 18:00:34 +00:00
Jesse Wilson
3f26144165
Fix date adapters to work when run in any time zone.
2011-09-28 17:56:54 +00:00
Inderjeet Singh
cebda2b119
Fixed MapTest.testInterfaceTypeMapWithSerializer. This test for relying on JsonElement.toString() to have same behavior as gson.toJson(JsonElement). However, gson.toJson() skips nulls by default whereas JsonElement.toString() does not.
2011-09-27 15:38:02 +00:00
Inderjeet Singh
b2d5940a9b
Implemented runtime type serialization for keys and values of a map.
...
This fixes MoreSpecificTypeSerializationTest.testMapOfSubclassFields
2011-09-27 15:20:57 +00:00
Jesse Wilson
3b3a60d301
Use new instances of DateTypeAdapter and TimeTypeAdapter for each GSON; this guarantees that the TimeZone and Locale are what they should be
2011-09-26 21:44:08 +00:00
Inderjeet Singh
2f0fbf6bcc
deleted code that didnt really do anything as there are no default old-style type adapters.
2011-09-26 17:45:06 +00:00
Inderjeet Singh
c1bac6debf
Converted Date type adapter to the new style. This was the last remaining old style default type adapter.
2011-09-25 21:51:28 +00:00
Inderjeet Singh
81854db4ac
Converted java.sql.Timestamp type adapter to the new style.
2011-09-25 21:35:36 +00:00
Inderjeet Singh
f9b6c2095f
Converted java.sql.Time type adapter to the new style.
2011-09-23 18:42:45 +00:00
Inderjeet Singh
467011c7ab
Allowed users to override default type adapters for various classes.
2011-09-20 00:27:33 +00:00
Inderjeet Singh
8217aca925
Converted java.sql.Date type adapters to the new style.
2011-09-20 00:26:37 +00:00
Inderjeet Singh
d20df34b8b
Converted Calendar/GregorianCalendar type adapters to the new style.
2011-09-20 00:08:33 +00:00
Inderjeet Singh
4402240294
Converted Number type adapter to the new style.
2011-09-19 17:02:02 +00:00
Inderjeet Singh
2780a2a9bf
Fixed eclipse warnings.
2011-09-16 06:03:16 +00:00
Inderjeet Singh
b5f8ef6e16
Converted CharacterTypeAdapter to the new style.
2011-09-16 05:58:41 +00:00
Inderjeet Singh
882c14a367
Added support in Gson for serializing/deserializing from primitive char.
...
Created a new class for character/char tests, PrimitiveCharacterTest. This is the start of breaking down PrimitiveTest into smaller chunks.
When MiniGson can not find a type adapter for a type, revised the message to say can't handle instead of can't serialize.
2011-09-16 05:52:32 +00:00
Inderjeet Singh
fd502f4e79
removed unused method.
2011-09-16 05:41:04 +00:00
Inderjeet Singh
c71e61cf48
Converted EnumTypeAdapter to new style.
...
Got rid of default Hierarchy Serializer/Deserializers from DefaultTypeAdapters.
Got rid of methods for gettting default serializers/deserializers/instance creators. Instead we reuse the static final instances.
Fixed warnings in TypeAdapters where a parameterized type T was hiding the parameterized T in methods.
Removed support to unwrap single element array of enums into enum values. Also removed the test that verifies this behavior.
2011-09-16 05:40:05 +00:00
Inderjeet Singh
915c5d4d6f
Converted BitSetTypeAdapter to the new style.
2011-09-16 05:02:30 +00:00
Joel Leitch
b90b43ea47
A few minor fixes and one incompatible Java 1.6 API call.
2011-09-16 04:55:52 +00:00
Inderjeet Singh
6b2c275b5c
Deleted Long, Float and Double serializers from legacy DefaultTypeAdapters. This stuff is not invoked anymore as the MiniGson takes care of it.
2011-09-16 04:06:33 +00:00
Inderjeet Singh
4a6c084ef7
removed JDK 1.5 incompatible use of @Overrides annotation on overridden interface methods.
2011-09-16 03:27:48 +00:00
Jesse Wilson
51a9596d06
Make Dates test slightly more robust to time of day issues. The test still fails outside of PST when run as a part of a larger suite because GSON captures a static snapshot of the system time zone at GSON-creation time.
2011-09-12 06:02:48 +00:00
Jesse Wilson
a98d6eae47
Fix the map type adapter to support array serialization natively.
2011-09-12 05:51:17 +00:00
Jesse Wilson
d43cf5ea35
obsolete class!
2011-09-11 23:03:22 +00:00
Jesse Wilson
25c6ae177b
Down to 22 failing tests.
...
Consolidated all of the different code paths that we use to construct instances. We now have an ObjectConstructor class that knows what type it constructs; this means that we don't need to ever do reflection to lookup a constructor at construction time.
Cleaned up some buggy type adapters, particularly around handling of null.
Removed dead code for object graph navigation.
Moved some classes into 'internal' so they are visible to the 'bind' subpackage.
Turned some TypeAdapterFactory/TypeAdapter pairs inside out so that the TypeAdapter is now the inner class. This is necessary so that the factories can take parameters.
Added an API to request the 'next' type adapter for a type. This allows type adapters to compose other type adapters. We're using this in two places:
- where the user has excluded a type from serialization but not deserialization, we need to use the "default" deserialization but interpose null on serialization. We create a type adapter that delegates for one and returns null for the other.
- similarly when a DOM type serializer is registered but no deserializer, or vice versa.
This is the biggest change to the MiniGson core.
For backwards compatibility, return null for the empty string.
Simplify JsonSerializationContext/JsonDeserializationContext to simply call through to GSON. SerializeDefault is currently unsupported.
More useful error messages when calling getAsBoolean on a JsonNull.
Remove currently unused MemoryRefStack. We might need this back again, though wiring it back in will be much more difficult because we don't interject ourselves between the users' various type adapters.
2011-09-11 07:04:56 +00:00
Jesse Wilson
cdd5d80b85
Support writing maps with non-string keys
2011-09-09 08:17:20 +00:00
Jesse Wilson
f50cce6d14
Don't call deserializers with null
2011-09-09 08:13:50 +00:00
Jesse Wilson
ee9ffa808a
If the reflective type isn't as expected, fail with a JsonSyntaxException
2011-09-09 08:10:57 +00:00
Jesse Wilson
1bb48694f4
Permit the null key, which is written as "null"
2011-09-09 08:10:21 +00:00
Jesse Wilson
d22e11b184
Let the user override the byte[] type adapter
2011-09-09 08:04:28 +00:00
Jesse Wilson
2f0c617d8d
Use floating point comparison for all non-integral Number types (such as LazilyParsedNumber)
2011-09-09 08:01:51 +00:00
Jesse Wilson
2ee89879e1
New failing test to show that JsonPrimitive.equals() is broken for values that are out of 'long' range
2011-09-09 07:58:52 +00:00
Jesse Wilson
e756608568
Forbid custom serializers for primitive types (so we can avoid boxing in the reflective and array adapters)
2011-09-09 06:26:21 +00:00
Inderjeet Singh
fede584b98
Gson 2.0 converts JSON with type Object.class into something meaningful such as a Collection of primitives or Maps. Updated tests for the new behavior.
...
Changed $Gson$Types.getCollectionElementType to handle wild-card sub-classes of collections and raw collections.
2011-09-09 06:23:17 +00:00
Inderjeet Singh
6f6d3b221e
Added support for constructing Queues and SortedSet while handling collections.
2011-09-09 05:49:30 +00:00
Jesse Wilson
f3c0a96f44
Support incoming nulls in all default type adapters
2011-09-09 05:46:50 +00:00
Jesse Wilson
9424949245
Don't unwrap single-element String arrays
2011-09-09 05:41:35 +00:00
Jesse Wilson
99801915aa
More code through the same fromJson path
2011-09-09 05:40:34 +00:00
Jesse Wilson
da67003eef
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)
2011-09-09 05:23:01 +00:00
Jesse Wilson
a7e9ac3612
Don't support oversized values like 30-character integers
2011-09-09 05:11:59 +00:00
Jesse Wilson
e19672d0a3
Throw the right exceptions when primitives fail to parse.
2011-09-09 05:04:24 +00:00
Inderjeet Singh
ba283925ae
Deleted unneeded Long deserializer.
2011-09-09 05:02:19 +00:00
Jesse Wilson
9db0c53217
Adapt bytes
2011-09-09 04:39:29 +00:00
Inderjeet Singh
a8133efeb8
removed old-style Collections type adapter since the new one covers all cases.
2011-09-09 04:22:57 +00:00
Jesse Wilson
f67940cb63
Retire two old bad features
...
- overriding primitive type adapters
- auto unwrapping of single element arrays
2011-09-09 04:20:25 +00:00
Inderjeet Singh
ea9c0236c7
Converted InetAddress type adapter to new style.
2011-09-09 04:02:12 +00:00
Jesse Wilson
0aab1d0659
Support calling private constructors
2011-09-09 03:42:03 +00:00
Jesse Wilson
4f6a36d68f
Support reading nulls into strings
2011-09-09 03:40:39 +00:00
Jesse Wilson
6029afb72d
Use MiniGson's list adapters
2011-09-09 03:35:11 +00:00
Jesse Wilson
3aeb70e030
Adapter for Object.class
2011-09-09 03:31:16 +00:00
Inderjeet Singh
9fb39c89ea
Switched Locale type adapter to new-style.
2011-08-26 03:14:01 +00:00
Inderjeet Singh
f9976f4b01
Switched Short, URI, URL, UUID, StringBuilder and StringBuffer type adapters to new-style.
2011-08-26 02:33:54 +00:00
Inderjeet Singh
9b6954decd
Additional tests to verify handling of bytes.
2011-08-26 01:11:50 +00:00
Inderjeet Singh
bafc43afae
removed unneeded exception catch clause.
2011-08-19 03:16:51 +00:00
Inderjeet Singh
84c71409da
Removed Gson type adapters for boolean, integer, float, double, String, BigDecimal and BigInteger.
...
Switched Gson.fromJson() methods to use miniGson directly instead of using a DOM.
2011-08-19 03:13:06 +00:00
Joel Leitch
a85f9b81b0
Wrap IOException into a JsonIoException instead of RuntimeException.
2011-08-19 02:35:29 +00:00
Jesse Wilson
ff88ac32f2
Use MiniGSON for deserialization.
2011-08-12 18:24:20 +00:00
Joel Leitch
70965eae03
Adding new type adapters for BigInteger and BigDecimal types.
2011-08-12 02:20:48 +00:00
Inderjeet Singh
57ea7ff9f3
Restored this behavior for serialization: (as verified in CustomSerializerTest)
...
First preference: a type adapter registered for the runtime type
Second preference: a type adapter registered for the declared type
Third preference: reflective type adapter for the runtime type (if it is a sub class of the declared type)
Fourth preference: reflective type adapter for the declared type
2011-08-12 02:18:02 +00:00
Inderjeet Singh
f7121ad87d
Restored this behavior:
...
If a type adapter is registered for a base class, then a field of that type is serialized with the type adapter instead of using the run-time type.
This fixes: CustomSerializerTest.testBaseClassSerializerInvokedForBaseClassFieldsHoldingSubClassInstances
2011-08-12 01:59:22 +00:00
Inderjeet Singh
ad5ff0f2d9
Created a wrapper for runtime type determination.
2011-08-05 00:41:24 +00:00
Jesse Wilson
fc99556f22
Support type exclusion strategies.
2011-08-05 00:25:49 +00:00
Inderjeet Singh
e9a971f680
Revised getRuntimeTypeIfMoreSpecific to ignore the parent and just focus on the value.
...
All uses of this method have already made a determination about the parent.
2011-08-05 00:13:01 +00:00
Inderjeet Singh
64dc53ffc4
Added support for runtime type determination while serializing collections and its subclasses.
...
This currently doesn't work since Gson register a hierarchy type adapter for Collections that takes precedence over this.
2011-08-04 23:55:52 +00:00
Jesse Wilson
e04d3fa882
Don't look for instance fields on interfaces.
2011-08-04 23:53:10 +00:00
Jesse Wilson
1885ba7dec
Restore support for serializeSpecialFloatingPointValues.
2011-08-04 23:12:49 +00:00
Inderjeet Singh
6e3bf07300
Added support for runtime type determination while serializing array elements.
...
Created a utility class Reflection to hold methods to find Runtime type and creating new Instances.
2011-08-04 23:02:06 +00:00
Jesse Wilson
aa067056c3
Restore support for long serialization policy.
2011-08-04 22:57:36 +00:00
Inderjeet Singh
5fc2db9e72
Parity with Gson behavior where we use runtime type of an object while serializing instead of the declared type of the field.
2011-08-04 22:27:25 +00:00
Inderjeet Singh
2813385c33
Parity with Gson behavior where we use runtime type of an object while serializing instead of the declared type of the field.
2011-08-03 03:19:43 +00:00
Inderjeet Singh
5c620c7e0a
Changed Gson behavior to reject duplicate fields in a class.
2011-08-03 03:05:12 +00:00
Inderjeet Singh
f1f8b666ec
Implemented support for FieldNamingPolicy with MiniGson.
2011-08-03 02:51:59 +00:00
Inderjeet Singh
d70fb90ef7
Added methods to convert to JsonElement in TypeAdapter.
...
Using lenient mode while working with Gson.
Handling nulls while invoking legacy Gson type adapters.
2011-08-03 02:40:18 +00:00