Commit Graph

192 Commits

Author SHA1 Message Date
Jesse Wilson
eb7b1e4ac7 Test attempting (and failing) to reproduce issue 215. 2010-08-27 07:10:00 +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
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
bc5b836103 Test demonstrating a bug reported in issue 182, wherein malformed JSON is emitted when an property name contains a double-quote. 2010-08-20 05:45:51 +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
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
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
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
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
389f918bb8 Add new performance test for large objects (many fields). 2010-05-19 21:29:58 +00:00
Joel Leitch
9c7bfc677a Allow cache size to be configured. 2010-05-19 20:47:27 +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
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
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
Inderjeet Singh
fff9147988 Added some tests to measure serialization and deserialization performance of Gson based on the discussion in http://groups.google.com/group/google-gson/browse_thread/thread/7a50b17a390dfaeb
Surprising just marking a field as exposed halves the performance.
2009-10-20 00:04:34 +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
e37add7836 Implemented some code review comments from r482 2009-10-09 01:35:45 +00:00
Inderjeet Singh
2bddd575b3 Code review changes from r476 2009-10-08 23:23:52 +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
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
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
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
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
fbf834c3f6 Implemented suggests from r469 code review. 2009-10-02 20:33:37 +00:00
Joel Leitch
b28864eaa0 Remove unused import. 2009-10-02 20:22:43 +00:00
Joel Leitch
912db55ba6 Added test for hasNext on JsonStreamParser. 2009-10-02 19:39:09 +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
40ca8b0537 Added copyright header per code review suggestion from r424 2009-10-02 18:46:56 +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