Commit Graph

256 Commits

Author SHA1 Message Date
Joel Leitch
279c0e87ed Update Precondition checks and have it throw a NPE instead. 2011-03-16 07:23:44 +00:00
Joel Leitch
7b223a8983 Adding JavaDoc to the enableComplexMapKeySerialization method on GsonBuilder. 2011-03-16 07:05:24 +00:00
Joel Leitch
ba0cd254a9 Clean up warnings. 2011-03-15 15:38:17 +00:00
Joel Leitch
e57ef0908b Add method to GsonBuilder to enable complex key serialization of maps. 2011-03-15 15:37:41 +00:00
Inderjeet Singh
0c35edab65 Fixed the bug where copyOf() for a ParameterizedTypeHandlerMap was failing when hierarchical type adapters for a sub class and its base class were present.
Fixed previously broken tests to verify the behavior that a hierarchical type adapter for a sub-class can be registered after registering a hierarchical type adapter for the base-class. The vice-versa is not allowed as it would result in hiding the sub-class hierarchical type adapter.
2011-03-14 23:22:50 +00:00
Jesse Wilson
ef7bd4c999 Don't document an API that we don't offer! 2011-03-14 21:50:14 +00:00
Inderjeet Singh
b489f4fb01 marked default type adapters as final classes 2011-03-11 22:20:39 +00:00
Inderjeet Singh
e26a6d5c18 removed the wrapping (regarding exception handling) of some primitive deserializers (numbers and boolean).
Added a number of additional tests that cover the cases of attempts to deserialize JsonObjects or arrays as primitives that must fail.
2011-03-11 22:14:18 +00:00
Jesse Wilson
43137b6b4f Fix unsafe allocations on Android 2011-03-11 00:44:15 +00:00
Inderjeet Singh
28567508ea Corrected Javadocs to indicate that NumberFormatException gets thrown instead of ClassCastException while attempting to convert a JsonPrimitive to a number. 2011-03-11 00:14:49 +00:00
Inderjeet Singh
baf9591d3b Made constructors package private for package private classes. 2011-03-10 23:55:16 +00:00
Inderjeet Singh
4e4f9b3a69 Preconditions.checkState() now throws IllegalStateException instead of IllegalArgumentException. This will potentiallly break backwards compatibility.
Removed unhelpful message while constructing exceptions.
2011-03-10 23:19:58 +00:00
Inderjeet Singh
52288d7127 rawtypes -> unchecked
Fixed spurious eclipse warnings on deprecation, missing classes or parameters, etc.
2011-02-24 22:47:55 +00:00
Inderjeet Singh
4be9767a28 removed unused imports 2011-02-24 20:18:03 +00:00
Jesse Wilson
3d006c90a2 equals & hashCode for subclasses of JsonElement.
Resolves issue 64.
2011-02-15 00:14:20 +00:00
Joel Leitch
4c41b11fce Comments from r723. 2011-02-14 22:26:17 +00:00
Joel Leitch
451a9dbe66 Add ability to allocate memory for an object without the use of the default constructor. 2011-02-11 18:22:07 +00:00
Jesse Wilson
b649f2768c Support unquoted single word strings in lenient mode!
Fixes issue 282.
2011-02-10 01:36:27 +00:00
Jesse Wilson
6e81cfdbb4 Locale-awareness for date parsing and formatting:
- always format in en_US for best interchange
 - always parse in en_US, system locale and ISO-8601
2011-02-10 01:06:22 +00:00
Joel Leitch
114633fbf9 Provide a means to add serialization or deserialization specific exclusion strategies. 2011-02-04 03:09:41 +00:00
Inderjeet Singh
ea48a1debf Fixed issue 175 by adding default type adapters for StringBuilder and StringBuffer. 2011-01-31 23:14:02 +00:00
Joel Leitch
56aa828350 Minor clean-up in Gson class. 2011-01-22 22:43:43 +00:00
Joel Leitch
fb7bd7b1b7 Deprecate the old FieldNamingStrategy interface and open up the FieldNamingStrategy2 instead to take its place. 2011-01-22 22:27:30 +00:00
Joel Leitch
b883f8f4aa Add new "Mode" enum and carry mode through Gson so exclusion strategies know whether it is currently serializing or deserializing.
Deprecate old ExclusionStrategy code since this new approach is more powerful.
2011-01-22 22:15:06 +00:00
Inderjeet Singh
2b9f81e8b5 Registering default type hierarchy adapters first and allow users to override them.
This allows the default EnumTypeAdapter to be overridden for a specific hierachy adapter for Enum with anonymized sub-classes.
2011-01-19 23:28:28 +00:00
Inderjeet Singh
edc71130c4 removed unneeded suppression of warnings. 2011-01-19 07:34:44 +00:00
Jesse Wilson
37dc0f8d3e Type adapter for maps. Supports both complex and non-complex keys. 2011-01-12 00:17:21 +00:00
Joel Leitch
439d931c5a Removing unused methods on Cache and synchronizing it since FieldAttributes contains a static instance of this type. 2011-01-10 23:20:37 +00:00
Joel Leitch
1e2fbd81f5 Adding default type adapter for InetAddress. 2011-01-10 23:03:48 +00:00
Joel Leitch
3926afbd30 Removing unused files with the new Types class. 2011-01-10 22:47:42 +00:00
Inderjeet Singh
8380d28e6f removed compiler warnings 2010-12-06 19:47:41 +00:00
Jesse Wilson
883ce465d5 Second half of adopting Guice's types code.
This removes a bunch of unnecessary public APIs and looks more like the GSON code that existed before this whole exercise. We no longer use TypeToken.isAssignable. I wrote a test that demonstrates at least one problem with that method, so I've deprecated it. We should be able to remove it release-after-next; nobody should be using this method anyway.

There are still some things that are public that shouldn't be. In particular there's some APIs in Types that are needed by TypeToken, which is unfortunately in a different package. Traditionally the fix is to create an 'internal' package and make the shared code public in the internal package. I'm not sure what we want to do for GSON; we could also use reflection (yuck) or duplicate the code (yuck).
2010-12-03 18:12:26 +00:00
Jesse Wilson
d1ddab2e6f Swap out GSON's type mechanics with the Type resolution code from Guice.
The most significant impact of this change is that fields whose types are type parameters should now GSONify just fine. For example, consider the class below.

abstract class Foo<A, B> {
   A a;
   B b;
   List<A> list;
   Map<A, List<B>> map;
}
class RealFoo extends Foo<String, Integer> {...}

This is a reasonable checkpoint but some work still needs to be done for this. In particular, the level of visibility of methods in TypeToken and Type should be reconsidered; we're exposing more than we need to!
2010-12-03 08:07:13 +00:00
Inderjeet Singh
6818edecf9 enabled GsonBuilder.registerTypeHierarchyAdapter since head is now for Gson 1.7 2010-11-25 00:16:06 +00:00
Jesse Wilson
1c5f5132d8 Revert most of r677: Required strings to be quoted even in lenient mode. As far as Inderjeet and I can tell, this is consistent with Gson 1.5. 2010-11-24 23:22:13 +00:00
Inderjeet Singh
db3f19e881 dropping GsonBuilder.registerTypeHierarchyAdapter() from 1.6 release. 2010-11-24 23:13:29 +00:00
Joel Leitch
0a3f5fa801 Required strings to be quoted even in lenient mode.
As far as Inderjeet and I can tell, this is consistent with Gson 1.5.
2010-11-16 22:14:40 +00:00
Inderjeet Singh
520259fefa removed eclipse warnings. 2010-11-12 19:21:16 +00:00
Joel Leitch
7d055fcb51 Fixing fromJson type casting. 2010-11-11 18:22:45 +00:00
Inderjeet Singh
eac1505670 Removed eclipse warnings about unneeded else statements and rawtypes/unchecked access. 2010-11-11 07:29:55 +00:00
Joel Leitch
32afd1a4e4 Fixing parsing of unquoted strings to be (somewhat) consistent with previous versions of Gson. The difference with this version is that Gson will throw a more specific exception rather than JsonParseException. 2010-11-10 02:02:57 +00:00
Jesse Wilson
103edb9c36 Don't return null on an unexpected EOF unless the document is empty. This brings us back to compatibility with GSON 1.5. 2010-11-08 19:16:05 +00:00
Jesse Wilson
4d0cd67cde Addressing code review feedback from r585 and r648. 2010-11-08 01:22:21 +00:00
Joel Leitch
f6a332971f Warning fixes. 2010-11-05 22:47:13 +00:00
Inderjeet Singh
f4098b5cf7 implemented feedback from r585 2010-11-05 22:18:35 +00:00
Inderjeet Singh
c3bae2d35e incorporating code review comments from r648 2010-11-05 21:51:29 +00:00
Jesse Wilson
832257234d New overloads for constructing MalformedJsonException 2010-11-05 20:58:41 +00:00
Joel Leitch
bdf5bef887 Fix JavaDoc on JsonSyntaxException 2010-11-05 20:34:27 +00:00
Inderjeet Singh
0b4bf7706a Changed JsonParser API to throw specific JsonIOException,JsonSyntaxException instead of the general JsonParseException 2010-11-05 20:31:52 +00:00
Inderjeet Singh
7b99419aea Removed compiler warnings. 2010-11-03 23:14:42 +00:00