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
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
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
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
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
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
99801915aa
More code through the same fromJson path
2011-09-09 05:40:34 +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
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
Inderjeet Singh
9fb39c89ea
Switched Locale type adapter to new-style.
2011-08-26 03:14:01 +00:00
Inderjeet Singh
f9976f4b01
Switched Short, URI, URL, UUID, StringBuilder and StringBuffer type adapters to new-style.
2011-08-26 02:33:54 +00:00
Inderjeet Singh
bafc43afae
removed unneeded exception catch clause.
2011-08-19 03:16:51 +00:00
Inderjeet Singh
84c71409da
Removed Gson type adapters for boolean, integer, float, double, String, BigDecimal and BigInteger.
...
Switched Gson.fromJson() methods to use miniGson directly instead of using a DOM.
2011-08-19 03:13:06 +00:00
Joel Leitch
a85f9b81b0
Wrap IOException into a JsonIoException instead of RuntimeException.
2011-08-19 02:35:29 +00:00
Jesse Wilson
ff88ac32f2
Use MiniGSON for deserialization.
2011-08-12 18:24:20 +00:00
Joel Leitch
70965eae03
Adding new type adapters for BigInteger and BigDecimal types.
2011-08-12 02:20:48 +00:00
Inderjeet Singh
57ea7ff9f3
Restored this behavior for serialization: (as verified in CustomSerializerTest)
...
First preference: a type adapter registered for the runtime type
Second preference: a type adapter registered for the declared type
Third preference: reflective type adapter for the runtime type (if it is a sub class of the declared type)
Fourth preference: reflective type adapter for the declared type
2011-08-12 02:18:02 +00:00
Inderjeet Singh
f7121ad87d
Restored this behavior:
...
If a type adapter is registered for a base class, then a field of that type is serialized with the type adapter instead of using the run-time type.
This fixes: CustomSerializerTest.testBaseClassSerializerInvokedForBaseClassFieldsHoldingSubClassInstances
2011-08-12 01:59:22 +00:00
Inderjeet Singh
ad5ff0f2d9
Created a wrapper for runtime type determination.
2011-08-05 00:41:24 +00:00
Jesse Wilson
fc99556f22
Support type exclusion strategies.
2011-08-05 00:25:49 +00:00
Inderjeet Singh
e9a971f680
Revised getRuntimeTypeIfMoreSpecific to ignore the parent and just focus on the value.
...
All uses of this method have already made a determination about the parent.
2011-08-05 00:13:01 +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
Jesse Wilson
e04d3fa882
Don't look for instance fields on interfaces.
2011-08-04 23:53:10 +00:00
Jesse Wilson
1885ba7dec
Restore support for serializeSpecialFloatingPointValues.
2011-08-04 23:12:49 +00:00
Inderjeet Singh
6e3bf07300
Added support for runtime type determination while serializing array elements.
...
Created a utility class Reflection to hold methods to find Runtime type and creating new Instances.
2011-08-04 23:02:06 +00:00
Jesse Wilson
aa067056c3
Restore support for long serialization policy.
2011-08-04 22:57:36 +00:00
Inderjeet Singh
5fc2db9e72
Parity with Gson behavior where we use runtime type of an object while serializing instead of the declared type of the field.
2011-08-04 22:27:25 +00:00
Inderjeet Singh
2813385c33
Parity with Gson behavior where we use runtime type of an object while serializing instead of the declared type of the field.
2011-08-03 03:19:43 +00:00
Inderjeet Singh
5c620c7e0a
Changed Gson behavior to reject duplicate fields in a class.
2011-08-03 03:05:12 +00:00
Inderjeet Singh
f1f8b666ec
Implemented support for FieldNamingPolicy with MiniGson.
2011-08-03 02:51:59 +00:00
Inderjeet Singh
d70fb90ef7
Added methods to convert to JsonElement in TypeAdapter.
...
Using lenient mode while working with Gson.
Handling nulls while invoking legacy Gson type adapters.
2011-08-03 02:40:18 +00:00
Inderjeet Singh
566c27cf21
Adapted legacy Gson adapters into mini Gson.
2011-08-03 02:17:42 +00:00
Jesse Wilson
98aa124589
Unsafe allocation for reflective type adapters.
2011-08-03 01:25:51 +00:00
Inderjeet Singh
b922500c23
For efficiency, calling setAccessible on all fields of a class in one method call instead of doing it individually.
2011-08-03 01:25:02 +00:00
Inderjeet Singh
f276d13827
Added support for deserialization exclusion strategy.
2011-08-03 01:19:26 +00:00
Inderjeet Singh
3331dcdab0
Using serializationExclusionStrategy while navigating through fields to decide which ones to skip.
2011-08-03 00:47:36 +00:00
Jesse Wilson
37abcf3637
Break 203 tests and adopt the new stream binding internally. Test fixes coming soon...
2011-08-03 00:28:02 +00:00
Jesse Wilson
60e6ed912d
Promote MiniGson to gson.internal.bind
2011-08-03 00:25:10 +00:00
Jesse Wilson
161b4babe8
Fix a pair of relatively benign off-by-one bugs. These only manifest if the source Reader returns characters one-at-a-time.
2011-07-22 15:50:26 +00:00
Jesse Wilson
befcfd908b
Skip a byte order mark (BOM) if it exists.
...
http://code.google.com/p/android/issues/detail?id=18508
2011-07-20 18:57:30 +00:00
Jesse Wilson
415437810a
Include line and column position in error messages.
2011-07-18 19:26:02 +00:00
Jesse Wilson
9cf579ef01
Use Streams instead of Escaper.
...
Fixes issue 345.
2011-07-12 23:50:00 +00:00
Jesse Wilson
d3a4b48ad9
Unconditionally escape unicode newline characters.
...
Fixes issue 341.
2011-07-12 16:05:22 +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
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
9196b23251
Refactoring: Separated type handler maps into two types: one for system-specified handlers and one for user-specified. system-specified handlers are the ones that Gson comes with (DefaultTypeAdapters).
2011-06-24 21:52:59 +00:00
Jesse Wilson
f74dffc6fd
Add deepCopy to JsonArray and JsonObject.
...
Resolves issue 301.
2011-06-17 21:46:28 +00:00
Joel Leitch
aa89773008
Quick fix for threading issue. Should maybe look into synchronizing this method instead.
2011-06-07 01:28:30 +00:00
Joel Leitch
533ea1755d
Fix typo
2011-06-03 19:05:53 +00:00
Joel Leitch
c9ee7adcc5
Start using JsonNull.INSTANCE everywhere and remove creation method.
2011-06-03 19:02:28 +00:00
Inderjeet Singh
8fd4072f9b
fixed javadocs
2011-06-03 19:01:08 +00:00
Inderjeet Singh
61b9a2cb17
Moved field creation to the field declaration to avoid inadvertent change from LinkedHashMap to something else.
2011-05-30 09:01:45 +00:00
Inderjeet Singh
9531c662da
suppressed deprecation warning.
2011-05-30 06:47:21 +00:00
Inderjeet Singh
44faec1eb1
removed the methods that return null for various getAs methods per discussions with Jesse and Joel.
2011-05-27 17:58:39 +00:00
Inderjeet Singh
e79bcde8bf
Using JsonNull.INSTANCE instead of JsonNull.createJsonNull() method
2011-05-25 16:55:57 +00:00
Inderjeet Singh
5d31558428
eliminated maven compilation problems with JDK 5
2011-05-25 16:13:36 +00:00
Inderjeet Singh
540d36e4bd
API Change: Implemented various getAs methods to return null.
2011-05-25 07:08:21 +00:00
Inderjeet Singh
5e2bc1b8f0
New Public API: Exposed the singleton instance for JsonNull.
2011-05-25 07:01:36 +00:00
Joel Leitch
572421b771
Open object construction in JsonDeserializationContext to leverage the same object construction as default gson deserialization.
2011-05-20 21:50:39 +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
Jesse Wilson
ce79e16f7a
StringPooling. This makes things up to 20% faster on dalvikvm for some data sets.
2011-04-28 22:08:06 +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
f291c4d33e
Fix a bunch of preserve-type issues:
...
- Issue 205
- Issue 294
- Issue 318
2011-04-20 22:27:51 +00:00
Joel Leitch
e345feb438
Comments from r821
2011-04-14 18:54: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
Inderjeet Singh
5552d17d05
removed assembly-descriptor.xml from Gson jar
2011-04-13 18:26:51 +00:00
Inderjeet Singh
9bfe443950
marked package private classes final
2011-04-13 15:57:11 +00:00
Joel Leitch
1c3d08794d
Fixed typo.
2011-04-13 07:49:30 +00:00
Joel Leitch
5770be4ed2
More fixes to JavaDoc.
2011-04-12 22:03:15 +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
ecf137fec3
More fixes to JavaDoc.
2011-04-11 19:01:07 +00:00
Joel Leitch
c5c7c5bb64
More fixes to JavaDoc.
2011-04-11 18:52:29 +00:00
Joel Leitch
49e7ee05fc
Fix method name by making it singular.
2011-04-11 18:44:19 +00:00
Joel Leitch
c266097310
Fix minor JavaDoc issue.
2011-04-11 18:33:46 +00:00
Joel Leitch
457b37f08e
Replace var-args with single parameter.
2011-04-11 18:09:59 +00:00
Joel Leitch
854b92a78f
Comments from r789
2011-04-07 18:00:12 +00:00
Inderjeet Singh
4bd261ae06
Made FieldNamingStrategy2 and its corresponding builder method package-private.
2011-04-07 17:41:35 +00:00
Inderjeet Singh
c15f570c72
Added a warning in the documentation of the internal package.
2011-04-06 01:08:12 +00:00
Inderjeet Singh
05ae10a144
removed the constructor in FieldAttributes that was only used in tests.
2011-04-06 00:51:01 +00:00
Joel Leitch
ddb0c8c825
Minor formatting fixes.
2011-04-06 00:43:57 +00:00
Inderjeet Singh
7afda06253
Added warning in GsonBuilder regarding setting date format correctly.
2011-04-06 00:35:05 +00:00
Inderjeet Singh
c8bd121db2
Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types.
...
Marked the two private classes in $Types as final.
2011-04-06 00:26:57 +00:00
Inderjeet Singh
8d3bfc0f47
Marked the getTypeInfoForField() method package private as it was inadvertently marked public.
...
Removed commented out code in pom.xml that is now obsoleted with sonatype syncing.
2011-04-06 00:13:31 +00:00
Joel Leitch
b4eb810347
Comments for r766.
2011-04-06 00:02:40 +00:00
Joel Leitch
52bf144859
Comments for r767
2011-04-05 23:57:13 +00:00
Joel Leitch
dc283e1121
Fixed comments from r774.
2011-04-05 23:36:05 +00:00
Joel Leitch
944081327b
More very minor cleanup.
2011-04-04 23:18:25 +00:00
Joel Leitch
f36c1bc222
Very minor cleanup.
2011-04-04 23:17:43 +00:00
Joel Leitch
7c42ef3e5d
Update incomplete comment.
2011-04-04 23:16:44 +00:00
Joel Leitch
2fb8c92812
Use more specific type for map serialization if possible.
2011-04-04 23:13:31 +00:00
Inderjeet Singh
50b4e3f4b9
Using getElement() instead of get() to get proper synchronization.
2011-04-04 23:00:19 +00:00
Inderjeet Singh
542a17c3bc
Incorporated comments from r710
2011-04-04 22:48:34 +00:00
Inderjeet Singh
56b7ab1b71
Incorporated feedback from r718
2011-04-04 22:23:51 +00:00
Inderjeet Singh
feb9617bf0
Incorporated comments from r726
2011-04-04 22:09:51 +00:00
Inderjeet Singh
bf4ab04413
replaced multiple caches in ReflectingFieldNavigator with a single one.
...
Two additional optimizations:
- storing the field list for the entire type hierarchy in the cache instead of navigating it every time.
- storing the resolved type for the field in FieldAttributes instead of using reflection every time.
2011-04-01 23:54:41 +00:00
Inderjeet Singh
9c894c7485
switched from accessing field to an accessor method for access in tests.
...
Strangely, this fixes the broken tests in the continuous build.
2011-03-31 18:57:55 +00:00
Inderjeet Singh
5bc80cd693
Moved Cache, LruCache, Pair, Primitives and UnsafeAllocator to com.google.gson and made them package private.
2011-03-30 13:59:06 +00:00
Inderjeet Singh
523f489863
Got rid of an unneeded method.
2011-03-29 21:38:08 +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
Jesse Wilson
4efb133b4a
bling bling
...
Prefix internal classes with $ to prevent them from interfering with IDE's auto import functionality.
2011-03-29 21:24:26 +00:00
Joel Leitch
5e74dabad9
Re-use Preconditions instead of re-writing them here.
2011-03-29 21:18:27 +00:00
Jesse Wilson
9bcb0c0b6b
Use the internal copy of preconditions
2011-03-29 21:13:31 +00:00
Joel Leitch
454f58a7b1
Adding in instance creator to instantiate the concrete Collection or Map class if known, otherwise fallback to a default instance.
...
Also, added some caching as part of the default constructor lookups.
2011-03-29 16:57:28 +00:00
Inderjeet Singh
ad921a0ee8
removed unused variable. eliminated unnecessary ObjTypePair creation.
2011-03-24 22:37:03 +00:00
Inderjeet Singh
4d9bec2206
Caching inheritance hierarchy for a type to reduce performance impact of reflection.
2011-03-24 22:28:45 +00:00
Inderjeet Singh
4a58dc3e2a
Moving AccessibleObject.setAccessible to where the fields are obtained by reflection.
2011-03-24 22:16:25 +00:00
Inderjeet Singh
0adf7f5e17
Caching fields for a class for reducing the need for reflection.
2011-03-24 22:13:51 +00:00
Inderjeet Singh
337d89cf3f
Removed ObjectNavigatorFactory
2011-03-24 20:19:41 +00:00
Inderjeet Singh
b51ffc1060
Removed eclipse warnings about missing overrides and declared exceptions that are never thrown.
2011-03-24 20:08:56 +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
b819307de8
refactored the field navigation using reflection out of ObjectNavigator.
2011-03-24 18:28:23 +00:00
Inderjeet Singh
6d3e0e92a5
Added a cache for no-args constructors to avoid expensive reflection everytime an object needs to be instantiated.
2011-03-23 18:31:39 +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
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
Inderjeet Singh
10db917e93
Updated fromJson and toJson signatures to indicate the kind of exceptions (JsonIOException, JsonSyntaxException) that can be thrown.
2010-11-03 19:46:29 +00:00
Inderjeet Singh
83539c534c
removed compiler warnings.
...
Added default serial version id for MalformedJsonException.
2010-11-03 13:28:09 +00:00
Joel Leitch
c6a4f55d1a
Fix for Issue #40 .
2010-11-02 03:32:39 +00:00
Inderjeet Singh
a224bb1e2b
added serial version id
2010-11-01 23:16:03 +00:00
Inderjeet Singh
ad7bd1f465
removed unused JsonFormatter classes.
2010-11-01 23:10:09 +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
Inderjeet Singh
43f2a0012b
Removed JavaCC parser definition and its generated classes.
2010-11-01 22:57:39 +00:00
Inderjeet Singh
abe244c099
renamed com.google.gson.stream.JsonSyntaxException to MalformedJsonException.
...
Throwing JsonSyntaxException instead of JsonParseException where we can detect a syntax error.
2010-11-01 22:48:52 +00:00
Jesse Wilson
c8c3a6965c
Fix a regression that expects different type adapters for long.class and Long.class. This is a temporary fix; later we may want to always use the canonical wrapped class.
2010-11-01 22:46:20 +00:00
Jesse Wilson
20d895ff95
Fix primitive wrapping and casting.
...
Issue: 235
2010-11-01 22:36:30 +00:00
Joel Leitch
d0977c2e3a
Exposing the declaring class for the field wrapped by FieldAttributes.
2010-11-01 22:31:48 +00:00
Inderjeet Singh
7ea5cc2b36
Added a new JsonSyntaxException to indicate syntax errors in Gson.
2010-11-01 17:53:31 +00:00
Jesse Wilson
d9feb90593
Small cleanup of exception conversion.
2010-10-31 04:58:23 +00:00
Jesse Wilson
b2005299e4
Make JsonSyntaxException public, so clients can differentiate between IO problems and malformed JSON.
2010-10-30 21:32:08 +00:00
Inderjeet Singh
2b993d83b6
Made the GsonBuilder registerTypeHierarchyAdapter a public method.
...
Updated the Gson version number to 1.6 and added @since tag for the new classes
2010-10-27 23:53:09 +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
91bee2a688
Throwing JsonIOException on write failures
2010-10-18 23:58:09 +00:00
Inderjeet Singh
18a9205a04
Added an exception class to indicate IO Errors.
2010-10-18 23:54:09 +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
202bbfeef0
Fixing the Java 1.5 build.
2010-09-02 09:29:26 +00:00
Jesse Wilson
747e3c3051
Support mixed streaming and databinding with new APIs.
2010-09-02 00:15:23 +00:00
Jesse Wilson
fa40b4c63a
Rename GsonReader to Streams; check that class in.
2010-09-02 00:10:02 +00:00
Jesse Wilson
486820f515
Fix some test problems.
...
JsonWriter was using suboptimal escape characters for newlines etc: unicode escapes rather than \x escapes.
JsonObjectTest was banning empty and whitespace-only keys. These values are permitted as of r585.
2010-08-28 08:18:13 +00:00
Jesse Wilson
ff7aa3f331
Escape only the required characters when emitting JSON. This means that instead of emitting
...
["foo\nbar", "baz"]
we'll emit this:
["foo
bar", baz"]
This simple change measured about ~35% faster for in-memory writes!
2010-08-28 07:29:22 +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
7a7bbf754c
Use JsonReader internally rather than JsonParserJavacc.
...
For raw parsing (ie. new JsonParser().parse()) the parse time has improved substantially. For example, JsonParserJavacc parsed my 48KiB buzz feed in 4.8ms. JsonReader parses the same feed in 0.9ms.
http://microbenchmarks.appspot.com/run/limpbizkit@gmail.com/com.google.gson.GsonBenchmark/430001
2010-08-27 05:59:18 +00:00
Jesse Wilson
765a9f1ecd
Brand new classes for streaming JSON efficiently.
...
Notable features:
- Efficiency. The parser is faster than the current javacc parser. It's also faster than popular libraries for JSON streaming.
- Toggle lenient/strict
- Toggle pretty/compact
- Friendly error messages on bad JSON
- GSON-quality Javadoc
- Non-execute prefix handling
This doesn't wire JsonReader up into Gson just yet. That's coming soon...
2010-08-26 08:44:02 +00:00
Joel Leitch
5bffa1f679
Fix for Issue 178.
2010-08-21 06:50:52 +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
Inderjeet Singh
24fd66f645
removed @since for non-public classes
2010-08-20 00:35:48 +00:00
Inderjeet Singh
dc60cb1931
Made FieldNamingStrategy2 is package protected class.
...
Made type hierarchy adapter registration package protected.
Marked some of the classes final.
Minor changes in the performance tests.
2010-08-19 00:10:42 +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
b2af57d288
Added checks to ensure that typeHierarchyAdapter being registered doesn't hide a previously existing one.
...
Fixed a bug where registerIfAbsent was adding type adapters in the reverse order of priority.
Added toString() to Pair.
2010-06-24 21:51:18 +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
Inderjeet Singh
6728c742d2
Updated log statements to be localizable.
2010-06-15 20:40:12 +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
9c7bfc677a
Allow cache size to be configured.
2010-05-19 20:47:27 +00:00
Joel Leitch
2610a2920d
Update Parser to add members to an JsonObject within a loop rather than a recursive call.
2010-05-19 20:44:27 +00:00
Joel Leitch
9816426bba
Add new Cache interface and LRU Cache implementation to cache field annotations per "Class" (rather than per instance). This results in a significant speed-up (approx. 3X) when serializing/deserializing the same classes over and over again.
2010-01-10 00:32:21 +00:00
Joel Leitch
e6496fddd6
Update JavaDoc to link to the correct interface (FieldNamingStrategy2).
2010-01-09 22:48:53 +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
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
c329d020b9
Make some fields final and initialize immediately.
2009-12-03 23:13:39 +00:00
Joel Leitch
33e816dcf0
More lazy initialization done for FieldAttributes.
2009-12-03 22:28:58 +00:00
Joel Leitch
641390b1a1
Lazily initialize fields in FieldAttributes to prevent multiple Java reflection invocations.
2009-12-03 22:17:39 +00:00
Inderjeet Singh
610580b8d9
exposed final fields of Pair for fast access. Pair is used quite a bit during serialization because of its use in ref stack.
2009-12-03 20:58:22 +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
fffb204cee
Removed import for java.util.Map.Entry.
2009-10-09 18:10:43 +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
Joel Leitch
6387c9028e
Updated JavaDoc formatting
2009-10-09 15:26:34 +00:00
Joel Leitch
81e6ae25f1
Make FieldAttributes public so it can be used by public clients.
2009-10-09 03:11:16 +00:00
Joel Leitch
282ef30280
Updating JavaDoc tag to @code instead of @link.
2009-10-09 03:03:04 +00:00
Inderjeet Singh
e37add7836
Implemented some code review comments from r482
2009-10-09 01:35:45 +00:00
Joel Leitch
6d60a7db1d
Fixed comments from r486.
2009-10-09 00:36:22 +00:00
Inderjeet Singh
2bddd575b3
Code review changes from r476
2009-10-08 23:23:52 +00:00
Joel Leitch
93b0008486
Adding restrictions on the JsonElements to disallow Java "null"s.
2009-10-08 22:03:08 +00:00
Joel Leitch
10c39317a1
Makes ExclusionStrategy public.
2009-10-08 21:52:56 +00:00
Joel Leitch
dc5922e703
Addresses comments in r481 (except for the interface change....leaving FieldAttributes as a class).
...
Change the exclusion order in ObjectNavigator to exclude a top-level class (if exclusion strategy suggests class should be skipped) even if it is marked with a custom (de)serializer.
2009-10-08 20:51:40 +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
Joel Leitch
839b0c2f94
Refactored exclusion strategies so that they can easily be exposed as part of the public API.
2009-10-07 09:23:14 +00:00
Joel Leitch
c892738fbb
Re-enabling the ' (apostrophe) escaping with valid JSON escaping.
2009-10-07 03:48:29 +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
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
ff74224815
Revised equals and hashcode of ObjectTypePair to ensure reference equality of object instead of value equality. Improved JavaDocs for various 1.4 API methods.
2009-10-05 18:17:52 +00:00
Inderjeet Singh
2716d96516
Revised ancestor stack to use both object and type
2009-10-03 04:45:12 +00:00
Joel Leitch
25ea878f66
Add some synchronization to the JsonStreamParser to ensure that the "next" method behaves according to the API.
2009-10-02 20:21:19 +00:00
Inderjeet Singh
1dcdd3fb3f
Implemented suggestions from code review r432 by adding a JsonNull for primitives if the value is null.
2009-10-01 22:15:53 +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
8567fe6c10
Implementing code review comment from r428: Using Polymorphism for exclusion strategies for expose annotations.
2009-10-01 01:37:57 +00:00
Inderjeet Singh
77c2c29316
Implementing code review feedback from r454: using isFirst instead of the Stack to keep track of whether to add commas or not.
2009-10-01 00:57:55 +00:00
Inderjeet Singh
fbefa59b66
changed synchronization on Date type adapter to be for the format object per code review comments on r452
2009-09-30 23:11:30 +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
563cd1e8e3
Adding the "since" tag.
2009-09-29 18:52:32 +00:00
Joel Leitch
ad4ff6996b
Adding new default field naming policy
2009-09-29 18:44:56 +00:00
Joel Leitch
553a619ebd
Allow dashes as part of the field name.
2009-09-29 18:40:08 +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
Inderjeet Singh
19ae6c0763
Fixed issue 162 by making default date adapter thread-safe by synchronizing serialize() and deserialize() methods.
2009-09-25 17:14:48 +00:00
Joel Leitch
b0f50bb4be
Return a "JsonNull" object for empty whitespace input into the JsonParser.
2009-09-23 19:00:05 +00:00
Inderjeet Singh
fdcd3945c5
Fixed issue 147.
...
Integral values (byte, short, integer, long, BigInteger) are now comparable to each other.
Floating point values (float, double, BigDecimal) are now comparable to each other.
2009-09-23 18:54:01 +00:00
Joel Leitch
50eb582657
Ensure that the JsonElement.toString() will always generate valid JSON (even when control characters/whitespace characters are used).
2009-09-23 18:28:03 +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
Inderjeet Singh
29ab864b2f
Fixed bug 158
2009-09-23 17:17:03 +00:00
Joel Leitch
c5812bb485
Fixed Incorrect JavaDoc
2009-09-22 19:10:53 +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
66649a1a62
Moved ancestor tracking into the serialization visitor. Deserialization process doesn't need ancestor tracking since JSON does not allow self-referential structures.
2009-08-31 16:38:50 +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
c13fc568c7
Fixed indentation and simplified equals method as per code review comments on r419
2009-08-18 18:07:25 +00:00
Inderjeet Singh
f4f596ec3d
Made JsonParser implement Iterator
2009-08-12 21:01:42 +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
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
4f0728f6a0
Fixed issue 126 by ensuring that parameterized type deduction is not done for transient fields.
2009-06-02 18:02:15 +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
cd9bd71092
Allow JS Keywords as field name. These names are quoted anyways (and are valid according to the JSON spec) so it should not cause any issues.
2009-05-19 17:59:32 +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
f418ab69a2
Implementing hashcode and equals for JsonPrimitives as value type equality.
2009-04-03 21:24:38 +00:00
Inderjeet Singh
84f0ddd6bb
Throwing a helpful error in cases where the user forgot to use the TypeToken idiom.
2009-04-01 22:24:10 +00:00
Joel Leitch
5c6d5a0d11
Remove unneeded exception handling in Gson class.
2009-04-01 19:26:10 +00:00
Inderjeet Singh
cee6c74960
incorporated code review comments from r379 by removing the catching of OutOfMemoryError and StackOverflowError in Gson.fromJson. This is obviated since JsonParser.parse catches these errors, and that was the primary source of these problems.
2009-04-01 17:15:01 +00:00
Joel Leitch
e9600e10cb
Made GregorianCalendarTypeAdapter consistent with the other default type adapters.
2009-04-01 17:07:23 +00:00
Inderjeet Singh
149604f0be
Made author tags consistent across the public api.
2009-04-01 17:03:31 +00:00
Inderjeet Singh
85f7c939f6
Renamed JsonParserImpl to JsonParserJavacc for clarity.
2009-03-31 17:58:35 +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
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
727dbcdd88
Fixed javadoc for toString() since we do not output valid Json for strings at the moment.
2009-03-20 18:06:52 +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
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
8f456831d4
Fixed Issue 104 by making FieldNamingStrategy to be public and allowing FieldNamingStrategy to be set in GsonBuilder
2009-03-11 21:53:02 +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
2c7cc620d4
Exposed API for JsonParser and added methods to Gson to deserialize from a parse tree.
2009-02-04 01:56:28 +00:00
Inderjeet Singh
f4c21abda6
updated javadoc in response to issue 97
2009-01-29 02:43:36 +00:00
Joel Leitch
764e4d9aca
Performance fixes after doing some profiling.
2009-01-20 08:38:21 +00:00
Joel Leitch
6a80791f13
Code cleanup and some minor performance fixes.
2009-01-20 01:36:54 +00:00
Joel Leitch
2cec661ff0
Removing some unnecessary code.
2009-01-20 01:00:59 +00:00
Joel Leitch
0b1ee35784
Code review suggestions for r361
2009-01-12 17:10:50 +00:00
Joel Leitch
e2cfc0cc19
Update GsonBuilder API to accept an enum for the serialize Long as string. This will be useful if/when we implement support to serialize a long type as an array of integers.
2009-01-11 06:11:29 +00:00
Joel Leitch
90a4619034
Minor fixes for pretty printing.
2009-01-11 05:01:23 +00:00
Joel Leitch
02decace26
Added the ability to deserialize a Map "key" object from a String into a complex Java type.
2009-01-06 07:09:19 +00:00
Inderjeet Singh
cc334475b0
Fixed issue 87 by adding support for deserialization of java.util.Properties
2008-12-31 01:01:57 +00:00
Inderjeet Singh
3690d362b9
incorporated feedback from r358
2008-12-30 22:42:36 +00:00
Inderjeet Singh
e839336eea
Incorporated comments from the code review r355
2008-12-30 19:03:43 +00:00
Inderjeet Singh
05f54f3552
Incorporated code review comments from r350
2008-12-30 18:54:33 +00:00
Joel Leitch
9612bb3601
Removing test file that I didn't mean to add in r355.
2008-12-28 23:14:44 +00:00
Joel Leitch
73d93e3322
Provide a setting to allow a client to skip the escaping of special HTML characters.
...
As well, remove the "/" from the list of special HTML characters since it is causing some incompatibilities.
2008-12-28 23:05:22 +00:00
Joel Leitch
1c87bd5993
Some minor update to our JavaDoc
2008-12-28 06:51:11 +00:00
Joel Leitch
f923f7f537
Add "@since" JavaDoc to the new methods in GsonBuilder.
2008-12-28 03:35:07 +00:00
Joel Leitch
458f2baa2f
Added special serialization of "Long". Now the client has the ability to output a long field as a JSON "String". This is useful for JavaScript clients that need to handle long values.
...
As well, this change does a major clean up of the custom type adapter handling and ParameterizedTypeMap creation.
2008-12-28 03:23:36 +00:00
Joel Leitch
859af0025c
Implement suggestions from self review of r350.
2008-12-28 02:05:40 +00:00
Joel Leitch
54a480774d
Add the ability to configure Gson to exclude serializing and deserializing of all "Inner Classes".
2008-12-28 02:00:31 +00:00
Joel Leitch
73117fe652
Wrapping UUID deserializer in exception wrapper to make it consistent with other deserializers
2008-12-28 00:00:12 +00:00
Joel Leitch
911a92bff9
Removal of all unnecessary "Default" InstanceCreators. While refactoring the code, I found a bug that these InstanceCreators were being called when inside an "Array". This bug is fixed in this change.
2008-12-27 23:43:16 +00:00
Inderjeet Singh
e0195fcc54
code review changes from r342
...
Enabled escaping of /
2008-12-23 18:18:14 +00:00
Inderjeet Singh
51881c7f4a
Added a GsonBuilder setting to enable serialization of special double types, NaN, Infinity, and -Infinity.
2008-12-20 01:26:14 +00:00
Inderjeet Singh
362a94ec74
Added deserialization support for Double NaN, Infinity, and -Infinity
2008-12-19 22:21:35 +00:00
Inderjeet Singh
f33a84c223
Added tests for ensuring that control characters are escaped by Gson.
2008-12-19 20:58:58 +00:00
Inderjeet Singh
e4fdea0fc1
Updated Gson escaper to not escape unicode characters. This is in response to Issue 80.
2008-12-19 20:41:53 +00:00
Inderjeet Singh
6dbdb272c0
Added checks to ensure that we do not serialize NaN or postiive or negative infinity for floats.
2008-12-18 23:41:44 +00:00
Joel Leitch
09720f28cf
Incorporated changes from r307 code review
2008-12-18 20:21:05 +00:00
Joel Leitch
a18a751240
Share the same JsonNull instance with the Gson code.
2008-12-18 20:14:29 +00:00
Inderjeet Singh
cbc6b4d939
Added checks to ensure that we do not serialize NaN or postiive or negative infinity for doubles.
2008-12-18 20:00:27 +00:00
Joel Leitch
0993d729e4
Added @since to the JavaDoc for the new methods added to JsonElement.
...
Suggested in the r296 code review.
2008-12-18 19:25:22 +00:00
Joel Leitch
fc65667d2f
Add support for wildcard type on Maps, Collections and other parameterized types.
2008-12-14 07:12:04 +00:00
Joel Leitch
ea79cd6812
Allow booleans and number to be deserialized into a "String" field/object.
2008-12-14 04:42:16 +00:00
Joel Leitch
0b5f3dc825
Added UUID as a default type supported by Gson.
2008-12-13 20:42:31 +00:00
Joel Leitch
d16553701b
Performing automatic refactoring using the IDE tools which does not take resources into consideration. This fixes the JavaCC Parser definition.
...
Goes with r325.
2008-12-02 23:48:10 +00:00
Joel Leitch
11a29b63b0
Implemented suggested changes from r324 code review.
2008-12-02 23:41:04 +00:00
Joel Leitch
b9e81f93c1
Fixed warnings and updated some JavaDoc.
2008-12-01 01:40:11 +00:00
Joel Leitch
6f59bc3bfe
Added "Until" type version. This new annotation allows you to remove members from the JSON output beginning at a certain version number.
...
This new annotation work in conjunction with the "@Since" annotation.
2008-12-01 00:10:04 +00:00
Joel Leitch
5ae7e1f803
Adding new convenience method to JsonObject for adding Booleans and Characters.
2008-11-30 23:36:29 +00:00
Joel Leitch
b90228dcc0
Enable serialization of nulls within Maps.
2008-11-30 23:01:14 +00:00
Joel Leitch
c9e48097ec
Do not overwrite a duplicate field value during seriailzation if one those fields is null.
2008-11-27 00:50:50 +00:00
Joel Leitch
b506183d94
Move isPrimitiveOrString() method from ObjectNavigator to JsonPrimitive.
2008-11-27 00:40:31 +00:00
Inderjeet Singh
9bcbb4cfdc
Fixed issue 52 by switching Gson.toJson methods to use Appendable instead of java.io.Writer
2008-11-26 19:13:14 +00:00
Inderjeet Singh
59be02d4de
Added support for accepting Object field names without quotes. Issue 41.
2008-11-26 17:52:46 +00:00
Joel Leitch
2effd57976
Deserialization will no longer call the default constructor or InstanceCreator if the object being deserialized has a custom deserializer.
2008-11-25 18:42:47 +00:00
Joel Leitch
0c98c2f8d1
More lenient parsing of Numbers and Booleans. Basically, can deserialize properly formatted stringr representations of numbers and booleans.
2008-11-20 19:40:12 +00:00
Joel Leitch
2250afe825
Allow serialization of Object in collections. This used to be supported before restructuring the Collection type handling.
2008-11-20 01:06:21 +00:00
Joel Leitch
3df2d44e40
Adding a "remove" method to the JsonObject class. Created a unit test to ensure it is functioning properly.
2008-11-19 01:22:21 +00:00
Joel Leitch
d5319d9e84
Parse all JSON numbers as either BigDecimal or BigInteger. From there we can properly convert into the proper primitive type if need be. This reduces the chance of losing precision with floating point numbers.
2008-11-18 20:26:15 +00:00
Joel Leitch
628a2c5b86
Added default serializer/deserializer for "Number"
2008-11-18 20:05:02 +00:00
Joel Leitch
788d2bfbbb
Fix parsing of double and big decimals that have an exponent but no fraction part.
2008-11-18 19:55:14 +00:00
Joel Leitch
cf2a457af7
Removed the TypeAdapter object from GSON now that the primitive objects and fields are created by a custom Type Adapter.
2008-11-15 05:11:28 +00:00
Joel Leitch
0d8150fe52
Major restructuring of Primitve type serialization and deserializtion. From the end-user's point of view there should be no difference other than the user can now override the default serialization/deserialization their own custom type adapter (not sure if there is a real use-case out there for this).
...
This restructuring greatly cleans up the code and reduces some complexity; however, there is more that can be done to clean this up (i.e. get rid of "InstanceCreators" for primitive Type Adapters).
2008-11-15 02:26:57 +00:00
Inderjeet Singh
3ff6bda2ad
Added equals and hashcode to JsonNull to ensure all instances of this class are the same.
2008-11-14 22:33:39 +00:00
Inderjeet Singh
9a69560d9f
During serialization, we now dont call custom serializers the field is null.
...
During deserialization, we do not call custom deserializer if the field is to be set to null. Moreover, changed the logic to set fields to null only if explicitly indicated in the incoming Json. This is different from past behavior where all fields not mentioned in incoming Json were set to null. Now they are set to whatever the default constructor will do.
2008-11-14 20:52:57 +00:00
Inderjeet Singh
e4ea6b1fd0
removed unused code.
2008-11-14 02:43:32 +00:00
Inderjeet Singh
6fa09b5ef6
Removed specialized handling of Enum types with the EnumTypeAdapter
2008-11-14 02:37:59 +00:00
Inderjeet Singh
40b77dfa6b
removed unused endVisitingObject method.
2008-11-14 02:32:48 +00:00
Inderjeet Singh
bcd1baefd5
deleted unused visitCollectionField method in the visitor. All of this functionality has now been replaced with the default CollectionTypeAdapter
2008-11-14 02:30:28 +00:00
Inderjeet Singh
0b6bbaf5f1
deleted unused visitCollection method in the visitor. All of this functionality has now been replaced with the default CollectionTypeAdapter
2008-11-14 02:25:41 +00:00
Inderjeet Singh
bc2c25f235
Removed ExceptionWrapper from serializers.
...
This is done since it is improper to throw a parse exception from serializers. Moreover, the serializers dont deal with external input, they deal with classes, so they need not guard against spurious input.
2008-11-14 02:17:19 +00:00
Inderjeet Singh
9245bebdba
For the Collection and Map types, using ObjectConstructor to create instance instead of hard-coding a specific type.
...
This helps is handling cases where the user is using their own subclass of Collection or Map.
Updated ParameterizedTypeHandlerMap to return the handler corresponding to Map and Collection for subclasses if user has not specified a specific handler.
Fixed the logic in JsonTreeNavigator to not output a comma if the first field of an object was null.
2008-11-14 02:11:46 +00:00
Inderjeet Singh
eaa43b76e4
Added a custom type adapter for Collection class. We will migrate the code to use it instead of special cases for collections all over. This type adapter is called at a few places already.
...
Also added tests for verifying that Gson can handle serialization and deserialization of sub types of Maps. The deserialization test fails currently.
2008-11-13 23:40:10 +00:00
Inderjeet Singh
cc90a68241
Fixed issue 68 by providing support to override default type adapters for
...
primitive types. Added a visitFieldUsingCustomHandler method to handle this in
the visitors.
2008-10-31 00:19:58 +00:00
Inderjeet Singh
c98d7bc340
Fixed issue 66 to allow escaped slash ( \/) as a valid Json escaped character.
...
Changed Gson version to 1.2.3.
2008-10-29 23:31:13 +00:00
Inderjeet Singh
7aa1d0f6aa
Reusing the JsonNull instance everywhere instead of recreating it.
...
This is a minor optimization, which is possible because JsonNull is a stateless object.
2008-10-24 20:35:22 +00:00
Inderjeet Singh
3cd665b199
Added support for serialization of raw maps.
...
Also, refactored tests for maps in MapTest class.
2008-10-21 22:37:41 +00:00
Inderjeet Singh
9dfa454f6d
Fixed issue 63 where Gson could not operate in a thread-safe manner. Resolved the issue by recreating ObjectNavigatorFactory for each call instead of reusing the same object everywhere. This is needed since ObjectNavigatorFactory had MemoryRefStack that was incorrectly being shared across calls.
2008-10-20 20:09:42 +00:00
Inderjeet Singh
745c8e2a83
Fixed issue 58 by disabling the use of field value actual type for all cases
...
except when it is marked as Object.
2008-10-14 18:55:59 +00:00
Inderjeet Singh
9726b4e172
updated Gson version number to 1.2.1
...
Removed unused productions from Gson grammar. Also removed unused imports.
2008-10-13 22:09:15 +00:00
Inderjeet Singh
5631132892
Fixed Issue 54 to enable serialization of fields that are declared of type
...
Object.
2008-10-13 21:12:41 +00:00
Inderjeet Singh
2b9fd47b72
Fixed issue 53 where default date instances were not getting
...
serialized/deserialized properly. Added support for time style as well by using he default formatter that uses time style.
2008-10-13 18:40:20 +00:00
Inderjeet Singh
cdd5163458
fix for bug 56 where Gson wasn't serialization null fields of type string,
...
collection and arrays properly even when serializeNulls was set.
2008-10-10 22:33:46 +00:00
Inderjeet Singh
d74ecbfe82
Updated JsonParser to use Token to match strings instead of productions. This
...
enables Gson to handle much larger strings (~10s of MB) than previously
possible (<100kb). This also reduces memory and stack requirements, and
increases Gson performance as well.
2008-10-10 21:52:02 +00:00
Inderjeet Singh
1abf693b70
Fix for Issue 55 where GSON was unable to deserialize JSON with single quotes
...
(') used for field name/values. Gson now supports different fields with-in the
JSON to use either single quote or double quote. However, a single field name
or value must use ' or "" to delimit itself.
2008-10-10 02:53:54 +00:00
Inderjeet Singh
0b9c739a7b
added additional tests for the default deserialization of dates.
2008-10-06 22:00:04 +00:00
Joel Leitch
1cad54f7b1
Fix pretty printing of interlacing arrays and objects.
2008-09-27 19:01:45 +00:00
Inderjeet Singh
7da18b96e8
fixed issue 46 by adding toString() methods to Gson, serializers, deserializers, and instanceCreators, and default type adapters.
2008-09-16 18:28:31 +00:00
Inderjeet Singh
57d1f32de5
moved gson as a project under trunk
2008-09-01 03:13:32 +00:00