Jesse Wilson
2c8bec27d4
Permit multiple top-level values in JsonWriter in lenient mode. Also fix some cases where we don't throw the right thing on a closed JsonWriter.
...
I'd prefer to not support multiple top-level values, but we support it in JsonReader and it's easier to be consistent. Kevin Hayen's patch pointed me in the right direction here, but I needed to do more work to cover some of the edge cases.
Fixes issue 397.
2012-02-12 20:42:16 +00:00
Jesse Wilson
5c978948a0
Remove some dead code.
2012-02-11 20:16:21 +00:00
Jesse Wilson
f40ac23e88
Write a test recommended by missing code coverage on TypeAdapter
2012-02-11 20:16:05 +00:00
Jesse Wilson
7b75efd09e
Write some tests prescribed by missing code coverage. I found a bug where our nonexecute prefix code causes a problem.
2012-02-11 20:15:39 +00:00
Jesse Wilson
dd86d63436
Use inner classes for BigDecimal and BigInteger type adapters
2012-02-11 20:14:23 +00:00
Jesse Wilson
a0afec71ff
Test case to demonstrate no such crash as reported in issue 408.
2012-02-11 18:19:54 +00:00
Jesse Wilson
bb8dca71c4
Restore ability of instance creators to create collection and map types. We inadvertently lost this in Gson 2.0 and 2.1. Nobody noticed!
2012-01-01 15:46:33 +00:00
Jesse Wilson
6cca23c172
Get GraphAdapterBuilder working for serialization and deserialization using InstanceCreators to get a sneak peek at a value under construction.
2012-01-01 13:42:44 +00:00
Jesse Wilson
d4a1e49e46
Delete some obsolete TODOs
2012-01-01 12:42:48 +00:00
Jesse Wilson
796a381279
Kill GsonInternalAccess. Clients to this were all broken because nobody was ever assigning INSTANCE.
2012-01-01 12:42:20 +00:00
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
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
905b7ebccc
Using single quote in JSON that would be deserialized. This makes the JSON easier to read.
2011-10-20 21:35:39 +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
cc5cbe5a1f
Integration test for long serialization policy.
2011-10-20 04:57:58 +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
3a3870591e
Tests to demonstrate that GSON 2 fixes some user-reported bugs.
2011-10-02 15:18:12 +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
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