Commit Graph

448 Commits

Author SHA1 Message Date
Jesse Wilson
f89e92aa9f Tighten up some of the fields naming policy code. The main thrust of this change is replacing classes like UpperCaseNamingPolicy with the corresponding method calls. Classes like CompositeFieldNamingPolicy are replaced by sequences of method calls. This also replaces unit tests with functional tests.
One nice benefit of this is a 3%/5.7KiB reduction in the size of gson.jar to 184KiB.
2011-11-21 05:08:23 +00:00
Jesse Wilson
f777a192ee Remove dead code and fold contents of single-member helper classes into their clients. 2011-11-20 21:02:26 +00:00
Jesse Wilson
a00c5ff9f1 Simplify inner strategy in LongSerializationPolicy. 2011-11-20 20:16:46 +00:00
Jesse Wilson
1540201713 Remove unused interface 2011-11-20 20:15:45 +00:00
Jesse Wilson
d391584d48 Register Gson 1.x tree-style adapters in the TypeAdapter.Factory list rather than in the ParameterizedTypeHandlerMap.
The motivation for this change is to give tree-style adapters precedence order in registration. This fixes the test I committed earlier today, where registration order was not honored.

This renamed ParameterizedTypeHandlerMap to the shorter 'TypeMap'. For type adapters, this is now only used for type hierarchy. We still need non-hierarchy support in TypeMap for instance creators; I'll be looking for workarounds to see if further simplification is possible here.
2011-11-20 19:55:01 +00:00
Jesse Wilson
777e17c723 No more system type adapters. 2011-11-20 18:03:46 +00:00
Jesse Wilson
7e760143fd Smash together MiniGson and Gson. This changes Gson to be the MiniGson rather than delegating to the MiniGson. It means that the MiniGson objects passed into streaming type adapters are now fully-capable 'Gson' objects.
The most notable impact of this change is that it adds several new public APIs:
 - The TypeAdapter abstract class
 - The TypeAdapter.Factory interface
 - Four new methods on GsonBuilder to register streaming TypeAdapters (via Factory, via Class, via TypeToken, and as a type hierarchy)
 - Three new methods on Gson to lookup streaming TypeAdapters (by type, by class, and to get the next type adapter) 

Still outstanding:
 - Write beautiful prose to document the new APIs above
 - Change GsonBuilder's precedence so that both old and new-style type adapters are registered in one lot
2011-11-20 15:23:08 +00:00
Joel Leitch
a92cf394e8 Fix compile issues found during release. 2011-11-13 20:04:29 +00:00
Joel Leitch
2c19c43905 Adding Jesse's name to the JsonElementReader file. 2011-11-13 00:27:57 +00:00
Joel Leitch
2cbddbbbc5 - Remove unnecessary catch block 2011-11-13 00:04:39 +00:00
Jesse Wilson
172143df7c Removing JsonObject.deepCopy() and JsonArray.deepCopy() 2011-11-12 23:32:44 +00:00
Jesse Wilson
0ac36805c2 Remove an unnecessary cast from example code. 2011-10-24 14:14:34 +00:00
Jesse Wilson
016261d9cf Throw JsonParseException in event of binding failures like type mismatches. 2011-10-24 01:32:46 +00:00
Jesse Wilson
0340e01f98 Support booleans as strings in stream binding. Remove support for interpreting "1" as true.
Interpreting '1' as true was not backwards compatible.
2011-10-23 21:41:30 +00:00
Jesse Wilson
052c9ce0ce Honor our 'ignore nulls' policy when converting objects to JSON trees. 2011-10-23 20:28:04 +00:00
Jesse Wilson
290fb69a50 Provide more diagnostics when a constructor fails. 2011-10-22 20:22:47 +00:00
Jesse Wilson
94d59b550e Give a nice toString on type adapter factories to make debugging easier. 2011-10-22 19:26:15 +00:00
Jesse Wilson
90c9eadda1 custom-collections 2011-10-22 19:25:30 +00:00
Inderjeet Singh
339d3dd4d0 The real reason for this CL is to claim commit #1000 :)
Tiny performance enhancement: Reordered type orders to move up String and Integer which are likely to be most common fields.
2011-10-20 21:42:45 +00:00
Inderjeet Singh
31964507c1 Updated SuppressWarnings annotations to Eclipse 3.6/3.7 which is unfortunately incompatible with Eclipse 3.5 (rawtypes vs unchecked)
This CL eliminates all eclipse warnings.
2011-10-20 21:32:46 +00:00
Jesse Wilson
194c18d20c Be backwards-compatible for serialization of maps whose keys aren't primitives. 2011-10-20 04:24:27 +00:00
Jesse Wilson
0e02cbb33e Nulls are here to stay. Sigh. 2011-10-14 03:20:05 +00:00
Jesse Wilson
5db4caeec5 A whole bunch of tests for support for null elements.
Fixes bug 369
2011-10-14 03:17:12 +00:00
Inderjeet Singh
c4a2291866 Deleted unused fields. 2011-10-02 20:45:26 +00:00
Jesse Wilson
65df3b97ba Add a type adapter for JsonElement, so it serializes just like everything else.
Fixes issue 362.
2011-10-02 16:59:56 +00:00
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
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
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
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
b2d5940a9b Implemented runtime type serialization for keys and values of a map.
This fixes MoreSpecificTypeSerializationTest.testMapOfSubclassFields
2011-09-27 15:20:57 +00:00