Commit Graph

428 Commits

Author SHA1 Message Date
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
Jesse Wilson
f602bce9f5 Nice documentation for TypeAdapter. 2011-12-03 19:46:25 +00:00
Inderjeet Singh
f3c14b4614 Added support for promoteNameToValue for JsonElementReader. 2011-12-03 02:35:46 +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
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
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
e9521471aa Fix typo: Paramterized was spelled wong. 2011-11-20 20:31:10 +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
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
90c9eadda1 custom-collections 2011-10-22 19:25:30 +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
194c18d20c Be backwards-compatible for serialization of maps whose keys aren't primitives. 2011-10-20 04:24:27 +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
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
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
Inderjeet Singh
47a36fd095 Fixed Eclipse warnings 2011-09-30 17:08:35 +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
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
2236c95c37 Death to serializeDefault and deserializeDefault 2011-09-28 18:00:34 +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
2780a2a9bf Fixed eclipse warnings. 2011-09-16 06:03:16 +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
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
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
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
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
Jesse Wilson
9424949245 Don't unwrap single-element String arrays 2011-09-09 05:41:35 +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
Jesse Wilson
9db0c53217 Adapt bytes 2011-09-09 04:39:29 +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
9b6954decd Additional tests to verify handling of bytes. 2011-08-26 01:11:50 +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
Inderjeet Singh
5c620c7e0a Changed Gson behavior to reject duplicate fields in a class. 2011-08-03 03:05:12 +00:00
Joel Leitch
7dca724292 Fixing import order. 2011-07-12 04:15:46 +00:00
Jesse Wilson
807aa97ee7 Don't use ambiguous timezone names.
Fixes bug 331.
2011-07-01 22:00:45 +00:00
Jesse Wilson
937019651a Trailing comma tests 2011-07-01 21:36:05 +00:00
Inderjeet Singh
62675b7f46 Added serializeDefault and deserializeDefault methods in contexts that only invoke system type adapters on the top-level object.
With this, the RuntimeTypeAdapterTest passes.
2011-07-01 21:29:20 +00:00
Inderjeet Singh
5f4e88f62a More tests to ensure that serialization works for parameterized types like A<B<C<D>>> without the need to specify type in toJson() 2011-06-25 20:14:09 +00:00
Inderjeet Singh
d347128e6f Implemented support for serializing objects of type Bar<Foo> without the need to specify their type explicitly in toJson method. 2011-06-25 20:04:14 +00:00
Inderjeet Singh
ef2f73180b added tests to illustrate and validate that Gson can serialize parameterized types without the need of explicit type token. 2011-06-25 19:43:05 +00:00
Inderjeet Singh
60e7c481fd Added complex map serialization tests in case the Map is defined with TypeVariables. 2011-05-30 09:38:38 +00:00
Inderjeet Singh
f2eb76eac9 removed deprecation warnings by using JsonNull.INSTANCE 2011-05-25 16:48:39 +00:00
Inderjeet Singh
b85daafb08 suppressed unchecked warning 2011-05-11 21:43:47 +00:00
Inderjeet Singh
0bcd1b341f Revised Gson to refuse to deserialize floating point numbers into integer types.
This is probably a break from the past: previous versions of Gson allowed truncating a floating point into a long or int. However, it wasn't consistent in this behavior. It disallowed converting a BigDecimal value into BigInteger, int or long. Refusing to deserialize such values is aligned with fail-fast approach of uncovering bugs.
2011-05-04 23:26:22 +00:00
Inderjeet Singh
824635158c Parsing numbers lazily as a performance enhancement.
This avoids needing to parse number if the equivalent object field doesn't exist.
It also avoids the performance penalty of trying to parse it eagerly as a big decimal, float etc.
2011-04-28 21:57:29 +00:00
Joel Leitch
4efeef1893 Make test a little more complex to show it actually fixed the bug. 2011-04-20 22:32:13 +00:00
Joel Leitch
f291c4d33e Fix a bunch of preserve-type issues:
- Issue 205
- Issue 294
- Issue 318
2011-04-20 22:27:51 +00:00
Joel Leitch
cf3615e38c Adding tests to verify 294. 2011-04-19 22:18:25 +00:00
Inderjeet Singh
e60274ed35 Added tests to ensure that subclass objects that are of a parameterized type are serialized per their declared type in lists or maps. 2011-04-19 20:49:48 +00:00
Inderjeet Singh
40045dc2e4 Added tests to ensure that subclass objects are serialized per their real type in lists or maps.
Currently, this doesnt happen for List and hence the test is marked as disabled.
2011-04-19 20:26:16 +00:00
Joel Leitch
d2cf574e86 Adding unit-tests to verify bugs. 2011-04-15 06:33:09 +00:00
Joel Leitch
c894fb6c23 Default support for BitSet. As well, provide more flexibility on getAsBoolean for a JsonPrimitive. 2011-04-14 02:42:47 +00:00
Joel Leitch
97d00f4930 Add test to verify issue 309. 2011-04-13 16:14:54 +00:00
Joel Leitch
4917fc7f76 Lift restriction on naming when using the "@SerializedNamed" annotation.
Fix for Issue 290.
2011-04-12 17:29:19 +00:00
Joel Leitch
49e7ee05fc Fix method name by making it singular. 2011-04-11 18:44:19 +00:00
Inderjeet Singh
4bd261ae06 Made FieldNamingStrategy2 and its corresponding builder method package-private. 2011-04-07 17:41:35 +00:00
Joel Leitch
f36c1bc222 Very minor cleanup. 2011-04-04 23:17:43 +00:00
Joel Leitch
2fb8c92812 Use more specific type for map serialization if possible. 2011-04-04 23:13:31 +00:00
Inderjeet Singh
542a17c3bc Incorporated comments from r710 2011-04-04 22:48:34 +00:00
Inderjeet Singh
1a9a54dcc2 incorporated review comments from r768 2011-04-04 21:27:37 +00:00
Joel Leitch
21ddfc9b12 Show default serialization and deserialization works with subclasses of an enum type. 2011-04-04 19:19:46 +00:00
Joel Leitch
5af0b16641 Updating Map tests. 2011-04-04 19:07:20 +00:00
Jesse Wilson
46a8e9b411 Test to demonstrate that we've fixed issue 302.
http://code.google.com/p/google-gson/issues/detail?id=302
2011-03-29 21:48:03 +00:00
Jesse Wilson
f718784f33 Use the date format for java.sql.Date and java.sql.Timestamp.
Fixes issue 230.
2011-03-29 21:36:19 +00:00
Inderjeet Singh
337d89cf3f Removed ObjectNavigatorFactory 2011-03-24 20:19:41 +00:00
Inderjeet Singh
13dc7b6f02 Made ObjectNavigator a reusable object. We now use just one instance of ObjectNavigator instead of creating one for each field/object. 2011-03-24 18:41:45 +00:00
Inderjeet Singh
005c93e383 removed unused no-args constructors 2011-03-23 18:48:03 +00:00
Joel Leitch
861e047a62 Create an "internals" package for classes that we do not want to share, but is needed across multiple pacakges.
As well, move non-Gson specific classes, such as Preconditions, to this new "internals" package.
2011-03-21 22:30:35 +00:00
Jesse Wilson
657688ca79 Test that the date format is honored, even in a collection.
http://code.google.com/p/google-gson/issues/detail?id=230
2011-03-21 22:10:33 +00:00
Jesse Wilson
e96b241556 Test that we can serialize classes whose fields are concrete collections. 2011-03-21 21:49:38 +00:00
Joel Leitch
a9507250f9 Add test for multiple calls to register complex map key serialization. 2011-03-15 15:41:19 +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
912add0779 (Failing) test cases for registering competing types. 2011-03-14 22:14:35 +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
Inderjeet Singh
52288d7127 rawtypes -> unchecked
Fixed spurious eclipse warnings on deprecation, missing classes or parameters, etc.
2011-02-24 22:47:55 +00:00
Joel Leitch
69661216a3 Minor clean-up of warnings (in 1.5) and added new test for non-Empty maps. 2011-02-11 18:22:58 +00:00
Jesse Wilson
b649f2768c Support unquoted single word strings in lenient mode!
Fixes issue 282.
2011-02-10 01:36:27 +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
Inderjeet Singh
a09c3ab1c5 Added tests to validate issue 272. The tests currently pass so it is not a valid bug. 2011-01-24 22:40:42 +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
Jesse Wilson
fd0f526fb0 Basic functional test for type hierarchy adapter. 2011-01-19 23:25:27 +00:00
Jesse Wilson
a526da7cdd Tests that demonstrate that type variables work.
Fixes issue 168.
2011-01-19 22:24:10 +00:00
Jesse Wilson
37dc0f8d3e Type adapter for maps. Supports both complex and non-complex keys. 2011-01-12 00:17:21 +00:00
Inderjeet Singh
d87eed510b Fixed compilation problem since we dropped registerTypeHierarchyAdapter method 2010-11-24 23:14:30 +00:00
Inderjeet Singh
98ff894863 removed unnecessary else clause. 2010-11-22 23:14:51 +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
279649986e Added a test to ensure that Gson handles repeated invocation of itself correctly.
Revised proto maven configuration to use Gson 1.6
2010-11-15 22:56:01 +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
Joel Leitch
6a951b427e Adding new tests (two of which are disabled, but prepping for 1.7). 2010-11-05 22:57:44 +00:00
Inderjeet Singh
83539c534c removed compiler warnings.
Added default serial version id for MalformedJsonException.
2010-11-03 13:28:09 +00:00
Inderjeet Singh
82a1a9511e removed a System.out.println from a test. 2010-11-03 01:25:57 +00:00
Inderjeet Singh
200bccef21 Added tests for issue 249 2010-11-03 00:15:03 +00:00
Joel Leitch
c6a4f55d1a Fix for Issue #40. 2010-11-02 03:32:39 +00:00
Jesse Wilson
dea7ab89fe Restore pretty printing. The pretty printing format isn't as compact as the previous format - for example arrays of integers are printed one-per-line, whereas the previous format compacted these to all sit on the same line. 2010-11-01 23:03:41 +00:00
Jesse Wilson
20d895ff95 Fix primitive wrapping and casting.
Issue: 235
2010-11-01 22:36:30 +00:00
Inderjeet Singh
d3eda04f33 Added support for deserializing from null input to a null value.
Added toString() method to ObjectTypePair.
2010-10-22 16:06:59 +00:00
Inderjeet Singh
2b1f3eec15 Removed a bunch of unused code and unnecessary else statements. 2010-09-28 13:42:43 +00:00
Jesse Wilson
4e28bf3a39 Check in a passing test for issue 204. 2010-09-03 06:44:41 +00:00
Jesse Wilson
747e3c3051 Support mixed streaming and databinding with new APIs. 2010-09-02 00:15:23 +00:00
Jesse Wilson
78d1011ec5 Test escaping HTML characters! 2010-09-02 00:03:18 +00:00
Jesse Wilson
7e1e4eab07 Remove the constraint that map keys mustn't be the empty string.
See bug 227.
2010-08-28 05:02:33 +00:00
Jesse Wilson
d5741b321f Don't exclude enum constants, even if they are anonymous.
See issue 226.
2010-08-27 07:26:35 +00:00
Jesse Wilson
eb7b1e4ac7 Test attempting (and failing) to reproduce issue 215. 2010-08-27 07:10:00 +00:00
Joel Leitch
3fc4bcc061 Minor test fixes. Explicitly fail test if the expected exception was not thrown. 2010-08-21 03:19:17 +00:00
Inderjeet Singh
de0f8da151 replaced unchecked suppressed warnings token with more specific rawtypes.
removed unused imports.
2010-08-20 16:27:46 +00:00
Inderjeet Singh
ed838ec104 replaced unchecked suppressed warnings token with more specific rawtypes 2010-08-20 16:20:37 +00:00
Jesse Wilson
8b5cc3256d Test demonstrating a bug reported in issue 178, wherein malformed JSON is emitted when a map key contains a double-quote. 2010-08-20 05:43:17 +00:00
Joel Leitch
89c18452ae Ensure date with pattern is not override with the "default" date type adapter when a custom JsonSerializer/JsonDeserializer is registered. 2010-08-18 23:58:52 +00:00
Inderjeet Singh
c3f61ee5ad Added a test to reproduce bug described in http://groups.google.com/group/google-gson/browse_thread/thread/9591c539e3c19d59
Seems like an invalid bug report as Gson can deserialize primitive values in Integer fields.
2010-07-19 23:32:24 +00:00
Inderjeet Singh
8aedbc84db Added a new GsonBuilder option to register a type adapter for a type hierarchy instead of a single type.
Upgraded Gson version to 1.5 since a new API call is being added.
2010-06-21 23:26:06 +00:00
Joel Leitch
9cd72ca7fb Add new tests with SerializedName annotation that contains a space in the name. 2010-05-28 02:13:11 +00:00
Joel Leitch
ba0154867d Add support to allow spaces in the JSON field name. 2010-05-26 17:40:19 +00:00
Joel Leitch
bf2a0e4e0b Adding tests to ensure the adapter from the old to new naming strategy is working properly. 2010-01-10 03:27:59 +00:00
Joel Leitch
e3af076ff2 Deprecate the FieldNamingStrategy interface and replace it with FieldNamingStrategy2. This is the first step to help make it easy to cache field annotations across all instances of a class, etc. 2010-01-09 22:43:27 +00:00
Inderjeet Singh
7079799890 Fixed issue 167 by adding support for TreeSet deserialization. Added tests for serialization/deserialization of treesets. 2010-01-08 19:14:42 +00:00
Inderjeet Singh
058f7344db Revised the setup for date/time tests to use PST time-zone. This fixes bug 184 by ensuring that tests are run in PST time-zone. 2010-01-08 18:53:39 +00:00
Inderjeet Singh
15fa10943c Fixed serializers and deserializers for java.sql Date and Time to ensure that Date does't serialize time, and time does't serialize the date portion. 2009-12-04 18:15:00 +00:00
Inderjeet Singh
ebf24fbda5 Fixed issue 134 by adding support for java.sql Date and Timestamp classses. 2009-12-04 01:21:13 +00:00
Joel Leitch
102f8b3a71 Adding a few more assert to the InstanceCreatorTest to ensure that the default values are set for sub class fields. 2009-10-09 21:23:51 +00:00
Joel Leitch
d87d3f807f Added functional tests for user defined exclusion strategy.
Added test to ensure empty/null properties are added for the JsonObject.
2009-10-09 21:12:07 +00:00
Inderjeet Singh
bc1e5c5c99 Ensured that custom deserializer is invoked with actual type returned for field values.
Fixed a bug where a top-level object was constructed with default values even when the custom deserializer tried to set it to null.
2009-10-09 19:41:33 +00:00
Inderjeet Singh
338758a0d3 implemented support for deserialization to deserialize to more specific type if an instance creator returns a sub-class. 2009-10-09 18:16:16 +00:00
Joel Leitch
de6af4411b Minor fixes. 2009-10-09 15:43:50 +00:00
Inderjeet Singh
60ef777efc Fixed custom serilization invocation to correctly handle nulls returned by custom serializer. 2009-10-09 15:28:05 +00:00
Inderjeet Singh
2bddd575b3 Code review changes from r476 2009-10-08 23:23:52 +00:00
Inderjeet Singh
e9c156b016 Added inheritance tests using toJson() method as well. 2009-10-08 19:32:15 +00:00
Inderjeet Singh
b634804533 Ensured that a base class custom serializer is run when the type is specified explicitly during serialization. For all other situations, ensured that the actual type of the object is taken into consideration while serializing. First a custom handler corresponding to the actual type is looked up, then a custom handler for the specified type.
Created some serialization specific tests regarding custom serializers. Revised some tests to use toJsonTree for better asserts instead of string matching.
2009-10-08 19:28:53 +00:00
Inderjeet Singh
536a968b32 Disabled escaping of single quote since it is valid for JSON (though invalid for JavaScript).
Added null checks in contexts since the custom type adapter can pass nulls.
2009-10-06 17:10:52 +00:00
Inderjeet Singh
d416361ac5 Added a test to ensure Gson can use JSON fields to store type information. 2009-10-06 04:25:28 +00:00
Inderjeet Singh
ae85e6cce6 A test to ensure that null values override default values when nulls are present in input Json during deserialization. 2009-10-06 01:55:44 +00:00
Inderjeet Singh
1da3ef9891 Ensured that a custom handler is not visited during deserialization.
Ensured that JsonTreeNavigator can handle null values as children of JsonObject. This is now possible since Gson exposes toJson(JsonElement) method to which the user can pass a JsonElement with null values.
2009-10-06 01:15:28 +00:00
Inderjeet Singh
2716d96516 Revised ancestor stack to use both object and type 2009-10-03 04:45:12 +00:00
Joel Leitch
fbf834c3f6 Implemented suggests from r469 code review. 2009-10-02 20:33:37 +00:00
Joel Leitch
0c2106f2ff Adding test for new field naming policies from r456 code review. 2009-10-02 19:12:15 +00:00
Inderjeet Singh
c64b79c0f9 Implemented suggestions from the code review of r436: throwing NoSuchElementException in case the stream hits EOF. 2009-10-01 18:34:11 +00:00
Inderjeet Singh
3b1056c097 Renamed JsonParserAsync to JsonStreamParser as that is a more appropriate name.
Added a TODO in JsonSerializationVisitor per code review of r453.
2009-10-01 17:46:28 +00:00
Inderjeet Singh
907082102d Added code to ensure that circular reference situations with custom handlers are detected.
Split CircularReferenceTest out of ObjectTest.
2009-09-29 20:43:31 +00:00
Joel Leitch
933a3e5150 Allow serialization of nulls in a "List<Object>" type. 2009-09-29 20:34:35 +00:00
Joel Leitch
e5ed1cc59a Added some more tests. 2009-09-29 20:24:48 +00:00
Joel Leitch
e73ad007a4 Added test that serialize interfaces. 2009-09-29 19:03:49 +00:00
Inderjeet Singh
e9a2a1d0f7 Fixed Issue 153 by using a stack to keep track of first elements at any level. 2009-09-29 17:52:49 +00:00
Inderjeet Singh
3e7ebf8556 Fixed issue 156.
Added support for serializing an object field (or array elements) as per its actual type.
Refactored inheritance related tests into its own test class. Added regression tests for issue 156.
2009-09-25 19:54:25 +00:00
Joel Leitch
8297437610 Reverting r499. 2009-09-23 19:25:50 +00:00
Joel Leitch
c6f762f36b Fix Warnings 2009-09-23 19:09:01 +00:00
Inderjeet Singh
3b0f8f4340 Removed all the JDK warnings about unused fields in test classes or unused constructors for use by Gson or instanceof calls on parameterized types. 2009-09-23 17:45:16 +00:00
Joel Leitch
18b301dfeb - Serializing of Object arrays.
- Fixed incorrect warning
2009-09-22 19:04:27 +00:00
Inderjeet Singh
82771f006c removed Java 1.5 warnings 2009-08-31 17:51:47 +00:00
Inderjeet Singh
cbcf7defa3 Updated Grammar for matching JsonArray to be left-associative rather than right-associative. Gson can now parse arrays of size over 11MB instead of 80KB which was the prior limit. Thanks for the tip, kenotron. 2009-08-22 01:03:27 +00:00
Inderjeet Singh
f4f596ec3d Made JsonParser implement Iterator 2009-08-12 21:01:42 +00:00
Inderjeet Singh
41a1f8b89e Added tests in response to http://groups.google.com/group/google-gson/browse_thread/thread/41478d30b9f100b5 2009-08-10 17:47:11 +00:00
Inderjeet Singh
b7cbfc5c34 Fixed Issue 141 by adding new APIs for writing out JSON string representation for JsonElements. 2009-08-07 20:58:41 +00:00
Inderjeet Singh
03a3cc83c3 Attempt to reproduce issue 140 2009-08-07 01:12:41 +00:00
Inderjeet Singh
64172d1dac Added support to serialize and deserialize array of java.lang.Object when the content is a primitive type. 2009-07-27 23:24:23 +00:00
Inderjeet Singh
6d50bcea87 Added serialize and deserialize parameters to the Expose annotation that control whether a field gets exposed during serialization or deserialization. 2009-05-19 23:47:53 +00:00
Joel Leitch
376385ac0e Add a single quote to the HTML set of characters that should be escaped. 2009-05-19 19:49:25 +00:00
Joel Leitch
abf4ab2d78 Fix project so it still compiles with JDK 1.5. 2009-05-19 17:51:02 +00:00
Inderjeet Singh
6e59e502c2 Refactored the Async parser interface out of JsonParser into a new class JsonParserAsync. Updated the JsonParser to detect Eof and return a null instead of throwing a ParseException. 2009-05-14 20:18:45 +00:00
Inderjeet Singh
0127891081 Added a new API method in JsonParser to allow reading of multiple JSON objects on a stream asynchronously. 2009-05-08 22:22:34 +00:00
Inderjeet Singh
b44bbbf5e7 Added an API method to create a tree of JsonElement from an object. 2009-04-03 21:33:01 +00:00
Inderjeet Singh
2034090b15 Changed version to 1.3
Made JsonParser.parse a non-static method.
2009-03-31 17:53:23 +00:00
Inderjeet Singh
8965d31ce9 made DEBUG final per the naming conventions. 2009-03-30 19:55:05 +00:00
Inderjeet Singh
e340801d25 Moved enum-related tests under EnumTest class. 2009-03-30 18:36:55 +00:00
Inderjeet Singh
4f727df749 Throwing JsonParseException when the user expected class doesn't match the JSON input during deserialization. 2009-03-27 23:17:46 +00:00
Joel Leitch
c9cb05fc72 Do not leak out a ClassCastException to our clients. 2009-03-27 19:43:33 +00:00
Inderjeet Singh
68f3899c1a Updated the security token to make generated Json non-executable. Removed the unneeded <data> element at the end. 2009-03-20 18:02:35 +00:00
Inderjeet Singh
b2b2e5dc0a Implemented enhancement request from issue 42 by supporting a new GsonBuilder setting generateNonExecutableJson() that prefixes the generated JSON with some special text that makes the output non-executable javascript. Gson now recognizes this special text in the input while parsing the JSON in fromJson and filters it out, if present. 2009-03-17 21:15:10 +00:00
Inderjeet Singh
1c5785be57 Tests to reproduce issue 95. The tests currently pass so the bug will be marked as invalid. 2009-03-12 20:54:00 +00:00
Inderjeet Singh
4fc6400f5c Fixed the test that broke while fixing issue 100 in r394 by using a TreeSet for SortedSets and HashSet for other kind of sets. 2009-03-12 18:17:14 +00:00
Inderjeet Singh
a595032a90 Fixed issue 100 by adding support for deserialization of collections of elements that do not implement Comparable. 2009-03-12 01:59:48 +00:00
Inderjeet Singh
3d1f7251c1 Added tests to reproduce issue 103. The tests pass at the moment, so we need more information in the bugreport. 2009-03-12 01:04:30 +00:00
Inderjeet Singh
809e3b5e21 Fixed bug 106 by adding custom serialization support for Gregorian Calendar. 2009-03-11 21:46:58 +00:00
Inderjeet Singh
16be7167ec Updated Gson grammar to support floating point numbers without a +/- after the E. So, 1.234567899E8 is now accepted by Gson as a valid floating point number. This fixed the bug http://code.google.com/p/google-gson/issues/detail?id=94
Also, updated Gson to use Javacc 4.2.
2009-03-05 23:05:29 +00:00
Inderjeet Singh
da8a1feee8 Added tests for the bugreport http://code.google.com/p/google-gson/issues/detail?id=99 2009-03-03 21:09:07 +00:00
Inderjeet Singh
d4a53ee2fc Added tests to verify JsonParser and related methods in Gson. 2009-02-07 00:20:30 +00:00
Joel Leitch
6a80791f13 Code cleanup and some minor performance fixes. 2009-01-20 01:36:54 +00:00