Jesse Wilson
323dfa0af5
Be strict in TypeAdapter's toJson/fromJson methods
2012-01-01 12:36:42 +00:00
Jesse Wilson
641590b5b6
Fill in some gaps in ExclusionStrategy's test.
...
Changes to GsonInternalAccess should have broken exclusion strategies, but didn't. Adding these tests cause the expected breaks.
2012-01-01 12:34:47 +00:00
Jesse Wilson
c4ea9a3d87
New Javadocs for Gson 2.1.
2011-12-31 20:53:38 +00:00
Jesse Wilson
caf64dbf55
Remove Javadocs without proper mime types set
2011-12-31 20:52:11 +00:00
Inderjeet Singh
6c78bf5247
made toJson/fromJson/toJsonTree methods public in TypeAdapter.
...
made Gson.getNextAdapter method public.
2011-12-31 08:52:59 +00:00
Inderjeet Singh
49525c8d64
Javadocs for Gson 2.1
2011-12-31 07:53:30 +00:00
Inderjeet Singh
73d973f1d7
[maven-release-plugin] prepare for next development iteration
2011-12-31 07:14:29 +00:00
Inderjeet Singh
2177850ba1
[maven-release-plugin] prepare release gson-2.1
2011-12-31 07:14:21 +00:00
Inderjeet Singh
498049b304
updated documentation for registerTypeHierarchyAdapter to cover TypeAdapter.
2011-12-31 06:00:28 +00:00
Inderjeet Singh
46d2d79ba7
Added javadocs for type adapter registration through registerTypeAdapter method.
2011-12-31 05:32:14 +00:00
Jesse Wilson
ecdf9150f6
Hide Gson.getNextAdapter() for the current release.
2011-12-31 05:30:40 +00:00
Jesse Wilson
4057b98bab
Implement all but the most difficult part of graph type adapter's deserialization. The catch is we want to return an instance that we don't have yet. It's on the stack, but we don't have a handle to it because it's inside the 'nextTypeAdapter' who is busy populating its fields.
2011-12-30 08:27:24 +00:00
Jesse Wilson
4cb1b88115
Test for registerTypeHierarchyAdapter() using Date.class
...
Fixes issue 352.
2011-12-29 07:27:33 +00:00
Jesse Wilson
6d2cf4a853
Test for excludeFieldsWithModifiers().
...
Fixes issue 324.
2011-12-29 07:17:36 +00:00
Jesse Wilson
740d03ef0e
Don't call setAccessible(true) on fields we won't be setting or getting.
...
Fixes bug 191.
2011-12-29 07:11:43 +00:00
Jesse Wilson
8d5de3136c
Inline character unescaping. This saves ~10% on the READER_LONG benchmark.
2011-12-25 07:09:46 +00:00
Jesse Wilson
d7fbac0384
Rename TypeAdapter.Factory to TypeAdapterFactory.
2011-12-23 18:27:13 +00:00
Inderjeet Singh
2cd3f9707f
Incorporated feedback from r1082
2011-12-23 16:11:12 +00:00
Inderjeet Singh
82f18a257f
Implemented code review comments from r1090
2011-12-23 15:52:10 +00:00
Inderjeet Singh
bd937fe7b5
A type adapter for Class that throws an UnsupportedOperationException.
2011-12-22 22:31:43 +00:00
Jesse Wilson
13c1946621
More tests that skipValue() is no less strict.
2011-12-21 21:43:55 +00:00
Jesse Wilson
b28e518c7e
Hide toJson/fromJson APIs for the 2.1 release.
2011-12-21 21:30:18 +00:00
Jesse Wilson
dd9ae67af5
Test that skipValue is strict on unquoted strings.
2011-12-21 20:40:33 +00:00
Inderjeet Singh
b5ae3c945a
Incorporated code review from r949
2011-12-16 19:10:54 +00:00
Jesse Wilson
a3ca4e1312
Admit to a mistake in InetAddress' type adapter
2011-12-16 19:05:10 +00:00
Jesse Wilson
f24da51ca2
Fix dangling sentence.
2011-12-16 19:00:37 +00:00
Inderjeet Singh
4b8fd66c9d
Added a test for issue 389
2011-12-16 17:21:31 +00:00
Jesse Wilson
c01fc5c935
Fix tests broken by r1078.
2011-12-16 14:12:34 +00:00
Inderjeet Singh
8fcbd57e59
Updated Export-Manifest for OSGi to 2.1
2011-12-16 06:04:18 +00:00
Jesse Wilson
2ef7716209
Fix a broken Javadoc link to this.
2011-12-16 05:38:16 +00:00
Jesse Wilson
214234e202
Support @SerializedName on annotations.
...
Fixes issue 347.
2011-12-16 05:32:50 +00:00
Jesse Wilson
d891661c4a
Apply locale fix for date type adapter test.
...
Fixes issue 381.
2011-12-16 04:57:22 +00:00
Jesse Wilson
b7c3e0067c
Avoid local field accesses in nextString(char). This saves a modest 2%.
2011-12-14 06:07:40 +00:00
Jesse Wilson
d01d39aa26
Use locals instead of fields when figuring out the buffer's offset line and column. This saves about 2% when parsing twitter data.
2011-12-14 05:49:58 +00:00
Jesse Wilson
aa52435951
Apply an ugly optimization to save 5% on pretty printed JSON documents. This uses locals instead of fields in an inner loop to save field reads and writes.
2011-12-14 05:26:29 +00:00
Jesse Wilson
40cd660115
Always provide line and column information when a parse fails.
2011-12-13 23:42:10 +00:00
Jesse Wilson
8e8bf934f9
Inline the nesting stack to save ~20% on JsonReader parsing.
2011-12-13 04:08:48 +00:00
Jesse Wilson
61a549b74d
Don't allocate exceptions in the common case. On one benchmark this improved performance by 20%.
2011-12-13 03:24:35 +00:00
Jesse Wilson
eb2230caf0
Fix nullSafe() to not infinitely recurse on non-null input.
2011-12-06 15:35:52 +00:00
Jesse Wilson
e2e672740a
Fix broken test in registering competing type hierarchy adapters.
...
I actually tried to replicate this test but got an error "type adapters conflict" when I was doing it. I suspect the problem was that I was trying to use 'Object' as the base of my type hierarchy and that class is somehow special.
2011-12-06 15:29:48 +00:00
Inderjeet Singh
b19e187bdd
Minor improvements to TypeAdapter javadocs to promote the use of nullSafe.
2011-12-06 08:32:19 +00:00
Inderjeet Singh
0b734e46e1
Incorporated code review comments from r1061.
...
Made nullSafe() an instance method instead of a static method.
Updated code javadoc to match Guava style.
2011-12-06 08:18:00 +00:00
Jesse Wilson
d5ed0716db
Fix type adapter precedence so that last-registered wins (except for tree type hierarchy adapters, which were always last).
2011-12-06 05:09:18 +00:00
Jesse Wilson
296d843afd
Implement Inder's improvements on the TypeAdapter docs
2011-12-06 04:56:46 +00:00
Inderjeet Singh
91be944022
Added a new API method nullSafe() in TypeAdapter that can be used to avoid boilerplate handling of nulls in a type adapter.
2011-12-05 19:50:49 +00:00
Inderjeet Singh
538b7ca172
Updated various Maven plugins to their latest released versions.
2011-12-04 10:37:16 +00:00
Inderjeet Singh
756131d869
removed Eclipse 3.7 warnings.
2011-12-04 10:24:07 +00:00
Jesse Wilson
f602bce9f5
Nice documentation for TypeAdapter.
2011-12-03 19:46:25 +00:00
Inderjeet Singh
8ee2c24f61
renamed JsonElementReader to JsonTreeReader
2011-12-03 02:37:27 +00:00
Inderjeet Singh
f3c14b4614
Added support for promoteNameToValue for JsonElementReader.
2011-12-03 02:35:46 +00:00
Jesse Wilson
8f8e69a364
Add @since tags.
2011-12-02 23:11:28 +00:00
Jesse Wilson
26ab404599
Cleanup names for TypeAdapters.
2011-12-02 22:57:30 +00:00
Inderjeet Singh
2da01fb183
Deleted deepCopy as GsonBuilder should not be designed as a reusable object.
2011-11-29 07:58:32 +00:00
Jesse Wilson
ec42d600af
Decode JSON literal types eagerly and with our own decoder. Previously we relied on Double.parseDouble() to decode tokens. Since that method is expensive, we deferred calling it unless absolutely necessary. Now we decode the literal type immediately. For efficiency we decode the token right out of the char buffer. This makes things more complicated but it saves many calls to charAt(). It also opens up the possibility to deferring string creation.
2011-11-27 16:50:45 +00:00
Jesse Wilson
852cd72059
Don't allocate a whole bunch of objects each time we deserialize a map key. This saves 20% on bug 375's benchmark.
...
The fix here is quite distasteful; I'm adding an ugly backdoor API for MapTypeAdapterFactory to fiddle with the internal bits of JsonReader. I'd like to revisit this sooner or later, but for now I'll take the speedup.
2011-11-26 15:36:08 +00:00
Jesse Wilson
4c06b01369
Cache all computed type adapters. On one particularly violent test (issue 375) this improves performance by 77%.
2011-11-26 15:30:38 +00:00
Inderjeet Singh
ddde79c861
Added a deepCopy() method in GsonBuilder. This allows a web-service to create a pre-configured GsonBuilder and then for each request, create a Gson instance by adding type adapters to a copy.
...
In TypeAdapter.Factory.create() method, using the term gson to refer to the Gson instance instead of a little ambiguous context.
2011-11-25 05:40:17 +00:00
Jesse Wilson
7e47f46ac1
Remove an unused method.
2011-11-23 13:39:33 +00:00
Jesse Wilson
bc68d7293c
Comment clean up.
2011-11-23 13:39:06 +00:00
Jesse Wilson
9a80d095d9
Fix a regression I introduced with the changes to type hierarchy registration. If the registered type was a raw type, we need to also match the parameterizations of that type.
2011-11-23 13:38:25 +00:00
Inderjeet Singh
a069f4d883
Added a failing test that demonstrates regression on tree-style type adapters.
...
In this test, we are registering a tree type adapter for Id but it never gets invoked. Instead, the reflective type adapter gets invoked causing an exception.
2011-11-23 09:49:03 +00:00
Inderjeet Singh
1c09e24220
inlined typeAdapter and typeHierarchyAdapter methods. Added some documentation for registerTypeHierarchyAdapterFactory.
2011-11-23 09:26:44 +00:00
Jesse Wilson
1794182a56
Commit to factories as the mechanism to lookup type adapters. This uses factories for type hierarchy adapters. We keep a separate list of factories for tree-style adapters registered with registerTypeHierarchyAdapter to guarantee that these come after the non-hierarchy adapters.
...
This drops support for type hierarchy instance creators. I 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, I think this might actually be an improvement!
2011-11-23 06:16:55 +00:00
Jesse Wilson
3cbe355cb6
Test precedence of type hierarchy adapters.
2011-11-23 05:13:17 +00:00
Inderjeet Singh
d1de4cf676
renamed GsonBuilder.factory() to GsonBuilder.registerTypeAdapterFactory()
...
revised GsonBuilder.registerTypeAdapter/registerTypeHierarchyAdapter to take streaming type adapters as well. Removed the typeAdapter() and typeHierarchyAdapter() methods from the public API.
2011-11-22 23:56:10 +00:00
Jesse Wilson
d1cee8443f
Whoops! The TreeTypeAdapter shouldn't be public API.
2011-11-22 07:47:06 +00:00
Jesse Wilson
aa2f61b7d8
Rename GsonExclusionStrategy to Excluder. The new class is its own factory, which simplifies its caller in GsonBuilder. It no longer implements ExclusionStrategy, which allows the callers to pass in a boolean for serialize/deserialize. This allows us to use one excluder for both code paths. The delegate ExclusionStrategy instances might end up not being shared so it has two lists internally.
2011-11-22 07:37:13 +00:00
Jesse Wilson
fed332906d
Create a single, monolithic class to manage all exclusion strategies. This gets our file size within target of 177KiB.
...
I intend to follow this up with a builder for our new class to avoid multiple-argument constructor calls.
2011-11-22 06:07:18 +00:00
Jesse Wilson
0ff7d980c5
Adjust LruCacheTest to use the Map API
2011-11-21 06:26:30 +00:00
Jesse Wilson
4da08b0ec6
Remove two implementation classes that weren't generally useful:
...
- The cache interface has only one implementation. Drop the interface; we can add it back later if necessary.
- The DefaultTypeAdapters class contains one member class. Just make that a top-level class.
2011-11-21 06:23:42 +00:00
Jesse Wilson
7def596775
Begin to tighten the ExclusionStrategy code. This replaces named classes with anonymous classes wherever we have a single instance of a type.
2011-11-21 06:14:23 +00:00
Jesse Wilson
e23973afec
Smash together ReflectiveTypeAdapterFactory and its subclass. The separation was useful earlier when we were contemplating keeping Gson and MiniGson separate.
2011-11-21 05:42:30 +00:00
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
e9521471aa
Fix typo: Paramterized was spelled wong.
2011-11-20 20:31:10 +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
3f5caea95e
New (failing) test to demonstrate that we're broken with precedence of streaming vs. nonstreaming type adapters.
2011-11-20 15:35:26 +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
Jesse Wilson
df31d2db16
Update Javadoc to 2.0 part 4 (got the SVN types right?)
2011-11-18 16:07:57 +00:00
Jesse Wilson
dbf5486615
Update Javadoc to 2.0 part 3 (got the SVN types wrong)
2011-11-18 16:04:10 +00:00
Jesse Wilson
fca0ff129f
Update Javadoc to 2.0 part 2
2011-11-18 15:59:20 +00:00
Jesse Wilson
2a72d949d0
Update Javadoc to 2.0 part 1
2011-11-18 15:57:31 +00:00
Joel Leitch
65e9215a07
[maven-release-plugin] prepare for next development iteration
2011-11-13 21:10:17 +00:00
Joel Leitch
878314c5b8
[maven-release-plugin] prepare release gson-2.0
2011-11-13 21:10:06 +00:00
Joel Leitch
b900dc4af8
Update maven release plugin.
2011-11-13 21:08:28 +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
Inderjeet Singh
3e303ef6f7
Excluded javadocs for internal packages. removed company name for Inder.
2011-11-13 00:03:14 +00:00
Jesse Wilson
3a3c5b2b1a
I'm move Gson 2.0 notes to the sites page.
2011-11-12 23:34:50 +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
00946277e8
Track change in thrown exception.
2011-10-24 05:03:06 +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
c226bd4f3f
Tests to illustrate differences between GSON 1.7 and 2.0
2011-10-23 22:44:13 +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