Commit Graph

47 Commits

Author SHA1 Message Date
Johannes Frohnmeyer 89ae8b48c2
Merge remote-tracking branch 'origin/master'
ci/woodpecker/push/woodpecker Pipeline was successful Details
# Conflicts:
#	extras/pom.xml
#	extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java
#	extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java
#	extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
#	gson/src/main/java/com/google/gson/Gson.java
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/main/java/com/google/gson/util/ISO8601Utils.java
#	gson/src/main/java/module-info.java
#	gson/src/test/java/com/google/gson/GsonTest.java
#	gson/src/test/java/com/google/gson/functional/ArrayTest.java
#	gson/src/test/java/com/google/gson/functional/CustomTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/DefaultTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
#	gson/src/test/java/com/google/gson/functional/InternationalizationTest.java
#	gson/src/test/java/com/google/gson/functional/Java17RecordTest.java
#	gson/src/test/java/com/google/gson/functional/JavaUtilConcurrentAtomicTest.java
#	gson/src/test/java/com/google/gson/functional/JavaUtilTest.java
#	gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnClassesTest.java
#	gson/src/test/java/com/google/gson/functional/JsonAdapterAnnotationOnFieldsTest.java
#	gson/src/test/java/com/google/gson/functional/JsonParserTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	gson/src/test/java/com/google/gson/functional/PrimitiveTest.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
#	gson/src/test/java/com/google/gson/functional/StreamingTypeAdaptersTest.java
#	gson/src/test/java/com/google/gson/functional/TypeAdapterPrecedenceTest.java
#	gson/src/test/java/com/google/gson/internal/bind/Java17ReflectiveTypeAdapterFactoryTest.java
#	gson/src/test/java/com/google/gson/internal/bind/JsonTreeReaderTest.java
#	gson/src/test/java/com/google/gson/internal/bind/JsonTreeWriterTest.java
#	gson/src/test/java/com/google/gson/internal/reflect/Java17ReflectionHelperTest.java
#	gson/src/test/java/com/google/gson/regression/JsonAdapterNullSafeTest.java
#	gson/src/test/java/com/google/gson/stream/JsonReaderPathTest.java
#	gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
#	metrics/pom.xml
#	metrics/src/main/java/com/google/gson/metrics/NonUploadingCaliperRunner.java
#	metrics/src/main/java/com/google/gson/metrics/ParseBenchmark.java
#	pom.xml
#	proto/pom.xml
2023-02-23 14:21:42 +01:00
Maicol 49b00d1a86
Port all Junit assert to Truth asserts (#2304)
* Port Junit assert to Truth in `com.google.gson.stream`

* Port Junit assert to Truth in `com.google.gson.regression`

* Port Junit assert to Truth in `om.google.gson.reflect`

* Port Junit assert to Truth in `com.google.gson.metrics`

* Port Junit assert to Truth in `com.google.gson.internal`

* Port Junit assert to Truth in `com.google.gson.internal.sql`

* Port Junit assert to Truth in `com.google.gson.internal.reflect`

* Port Junit assert to Truth in `com.google.gson.internal.bind`

* Port Junit assert to Truth in `com.google.gson.internal.bind.util`

* Port Junit assert to Truth in `com.google.gson.functional`

* Replaces `List.of` with `Arrays.asList` to grant legacy

* Simplify `==` asserts

* Simplify `.contain()` asserts + Minor fixes

* Simplify asserts
2023-01-31 11:20:54 -08:00
Johannes Frohnmeyer b6cc63919d
Merge remote-tracking branch 'origin/master'
ci/woodpecker/push/woodpecker Pipeline failed Details
# Conflicts:
#	.github/ISSUE_TEMPLATE/bug_report.md
#	.github/workflows/build.yml
#	extras/pom.xml
#	extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java
#	extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
#	extras/src/test/java/com/google/gson/interceptors/InterceptorTest.java
#	extras/src/test/java/com/google/gson/typeadapters/PostConstructAdapterFactoryTest.java
#	extras/src/test/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactoryTest.java
#	extras/src/test/java/com/google/gson/typeadapters/UtcDateTypeAdapterTest.java
#	gson/src/test/java/com/google/gson/CommentsTest.java
#	gson/src/test/java/com/google/gson/ToNumberPolicyTest.java
#	gson/src/test/java/com/google/gson/functional/EnumWithObfuscatedTest.java
#	gson/src/test/java/com/google/gson/functional/JsonParserTest.java
#	gson/src/test/java/com/google/gson/functional/LeniencyTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	gson/src/test/java/com/google/gson/functional/PrimitiveCharacterTest.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
#	gson/src/test/java/com/google/gson/functional/SecurityTest.java
#	gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
#	gson/src/test/resources/testcases-proguard.conf
#	metrics/pom.xml
#	metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
#	proto/pom.xml
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithAnnotationsTest.java
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithComplexAndRepeatedFieldsTest.java
#	proto/src/test/java/com/google/gson/protobuf/functional/ProtosWithPrimitiveTypesTest.java
2023-01-21 14:24:25 +01:00
Maicol 1a2170b99c
Port tests from JUnit 3 to JUnit 4 (#2294)
* Port tests from JUnit 3 to JUnit 4

* Port tests from JUnit 3 to JUnit 4

* Add `@Test` above `@Ignore`
2022-12-22 06:04:16 -08:00
Johannes Frohnmeyer 9409197165
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	gson/src/main/java/com/google/gson/stream/JsonReader.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessFilterTest.java
#	gson/src/test/java/com/google/gson/functional/ReflectionAccessTest.java
#	gson/src/test/java/com/google/gson/internal/bind/DefaultDateTypeAdapterTest.java
#	pom.xml
2022-10-31 12:44:34 +01:00
Marcono1234 3e3266cf48
Perform numeric conversion for primitive numeric type adapters (#2158)
* Perform numeric conversion for primitive numeric type adapters

This should probably not be visible to the user unless they use the
non-typesafe `Gson.toJson(Object, Type)` where unrelated number types can
be used, or when malformed generic containers are used. For example a
`List<Byte>` containing a Float.

This change also has the advantage of avoiding `JsonWriter.value(Number)`
for primitive type adapters. That method has some overhead because it needs
to make sure that the value is a valid JSON number. However, for primitive
numbers this check is redundant.

* Don't call `JsonWriter.value(float)` for backward compatibility

* Fix typo in comments
2022-10-04 07:22:26 -07:00
Johannes Frohnmeyer ce02cb3bc1
Merge remote-tracking branch 'origin/master'
# Conflicts:
#	gson/pom.xml
#	gson/src/main/java/com/google/gson/Gson.java
#	gson/src/main/java/com/google/gson/GsonBuilder.java
#	gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java
#	gson/src/main/java/com/google/gson/stream/JsonWriter.java
#	gson/src/test/java/com/google/gson/functional/ArrayTest.java
#	gson/src/test/java/com/google/gson/functional/MapTest.java
#	pom.xml
2022-09-14 19:20:24 +02:00
Johannes Frohnmeyer dc4e61ac7b
Several breaking changes 2022-05-17 21:20:10 +02:00
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