Commit Graph

900 Commits

Author SHA1 Message Date
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