Commit Graph

39 Commits

Author SHA1 Message Date
Marcono1234
e2e851c9bc
Add LazilyParsedNumber default adapter (#2060)
* Add LazilyParsedNumber default adapter

* Validate JsonWriter.value(Number) argument

* Fix incorrect JSON number pattern, extend tests
2022-01-28 11:26:28 -08:00
Marcono1234
b4dab86b10
Make default adapters stricter; improve exception messages (#2000)
* Make default adapters stricter; improve exception messages

* Reduce scope of synchronized blocks

* Improve JsonReader.getPath / getPreviousPath Javadoc
2021-11-01 15:08:04 -07:00
Degubi
7845c38077 Minor cleanups in deprecations and other warnings (#1522) 2019-10-03 15:49:24 -07:00
Egor Neliuba
44cad04a63 Allow deserialization of a Number represented as a String (#964) 2016-11-25 23:40:14 -08:00
Inderjeet Singh
fbb8696e83 Added tests for deserialization of double array 2015-09-01 17:49:34 -07:00
Joel Leitch
e4508227c5 Added test to use BigDecimal to parse number when requesting it as a long. 2013-05-13 20:37:33 +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
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
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
Inderjeet Singh
9b6954decd Additional tests to verify handling of bytes. 2011-08-26 01:11:50 +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
Joel Leitch
2fb8c92812 Use more specific type for map serialization if possible. 2011-04-04 23:13:31 +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
b649f2768c Support unquoted single word strings in lenient mode!
Fixes issue 282.
2011-02-10 01:36:27 +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
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
20d895ff95 Fix primitive wrapping and casting.
Issue: 235
2010-11-01 22:36:30 +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
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
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
Inderjeet Singh
e839336eea Incorporated comments from the code review r355 2008-12-30 19:03:43 +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
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
Inderjeet Singh
bc6ec50db9 incorporated fixes from code review of r341 2008-12-23 18:24:13 +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
53f7d26b6d removed tests for serialization of BigDecimal NaN, positive and negative infinity since BigDecimal can not be created with these values. 2008-12-19 17:46:24 +00:00
Inderjeet Singh
f7e4d5e4bb Added checks to ensure that we do not serialize NaN or postiive or negative infinity for BigDecimal. 2008-12-18 23:56:38 +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
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
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
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
3b8404dac5 refactored String related functional tests out in a separate test class. 2008-10-10 02:29:06 +00:00
Inderjeet Singh
57d1f32de5 moved gson as a project under trunk 2008-09-01 03:13:32 +00:00