Éamonn McManus
d65960b001
Merge pull request #1391 from mcumings/issue1390
...
Fix issue with recursive type variable protections to fix #1390
2021-08-02 16:43:19 -07:00
HiFromAjay
2d1981d39b
modify test cases for testing the exceptional behavior of get... methods [use fail(...), use JsonArray methods, remove unused values, formatting, #1909 , #1908 ]
2021-06-14 14:31:14 -06:00
HiFromAjay
55115a5ca2
Test cases for testing the exceptional behavior of get, getAsBoolean, getAsDouble, getAsInt, getAsJsonArray, getAsJsonObject, getAsLong, and getAsString methods of JsonArray class. These test cases, which we wrote according to the specified behavior of each method, that helped us in identifying the documentation bugs in JsonArray and JsonElement classes, which we submitted issues for (Issue #1908 ). Note that we have adapted these test cases based on similar tests from the JSON-java project ( https://github.com/stleary/JSON-java ).
2021-06-11 10:04:32 -06:00
Richard Hernandez
b39494dbe6
Fix fallback behavior of UnsafeReflectionAllocator when AccessibleObject isn't so accessible
2020-05-26 20:12:36 -07:00
Marcono1234
4fb215c9df
Move SQL types specific tests to separate test class
2020-05-23 23:31:03 +02:00
Marcono1234
380c4ec12c
Make dependency on java.sql optional
2020-05-23 23:30:53 +02:00
Marcono1234
361292f1c1
Fix warnings
2020-05-09 17:34:53 +02:00
Marcono1234
541252a9fb
Implement DefaultDateTypeAdapter in a type safer way
2020-05-09 17:34:52 +02:00
Marcono1234
9171715a88
Fix ISO8601UtilsTest failing on systems with UTC+X
...
Previously ISO8601UtilsTest.testDateFormatString() would fail on systems
where the time zone is UTC+X because getTime() returned "2018-06-24" for them.
Additionally the tests which previously changed the system locale and time
zone have been rewritten to create a UTC calendar instead. Setting locale
seems to not be necessary because ISO8601Utils.parse(...) does not do that
either.
2020-05-03 00:35:47 +02:00
Jiechuan Chen
4d735f1903
Add new testcases ( #1638 )
...
* Json Primitive Tests
* Json Tree Writer tests
* Add Tests for ISO8601Utils
* Add Tests for ISO8601Utils
2020-02-17 14:55:19 -08:00
Paul Kassianik
21fc362a7e
Fixed tests for java 11 ( #1454 )
2019-10-04 11:29:13 -07:00
Degubi
7845c38077
Minor cleanups in deprecations and other warnings ( #1522 )
2019-10-03 15:49:24 -07:00
Degubi
63ee47cb64
Refactor uppercaseFirstLetter, add additional field to test ( #1515 )
2019-04-26 15:49:22 -07:00
Degubi
c5a3f21fba
Refactor JsonParser to statics & fix tests
2019-04-15 22:35:10 -04:00
Jake Wharton
a817604a41
Add test coverage for passing null to JsonPrimitive constuctors
2019-03-11 10:50:22 -04:00
Lorenz Nickel
b75e1bbc79
Code cleanup (Removed spaces) ( #1474 )
...
* Removed double spaces in comments
* Unified comments
* Removed space
* Removed spaces in code
2019-03-03 11:18:06 -08:00
Mike Cumings
e2296f42d5
Fix issue with recursive type variable protections to fix #1390
...
When a type variable is referenced multiple times it needs to resolve
to the same value. Previously, the second attempt would abort
resolution early in order to protect against infinite recursion.
2018-09-25 16:09:48 -07:00
inder123
d84e26d80c
Issue 1242: Printing Gson version when throwing AssertionError and IllegalArgumentException ( #1321 )
...
On some versions of Android (probably on some variants of the popular Samsung S4 phone), an older version of Gson is suspected to be bundled in, and gets picked up from the system classpath.
For those versions, the applications that include the latest Gson fail unexpectedly. This debug print will help confirm this issue.
2018-05-17 09:41:21 -07:00
inder123
a6890bbaba
Fixed https://github.com/google/gson/issues/1310 ( #1311 )
...
* Fixed https://github.com/google/gson/issues/1310
Also renamed VersionUtils to more readable abstraction JavaVersion
Added support for debian naming convention
Using min supported version (6) as the default if JDK version can't be figured out
* Moved JavaVersion to an internal package
2018-05-09 13:10:08 -07:00
inder123
049bf84e68
Using sun.misc.Unsafe only through reflection to avoid binary dependency ( #1306 )
...
If sun.misc.Unsafe not found on Java 9, try field.setAccessible
Also removed exception traces when sun.misc.Unsafe or override are not found
2018-05-01 09:57:45 -07:00
inder123
1b28ff3cda
Added a test for deserialization of fields using lowercase-dot naming policy ( #1303 )
2018-04-27 18:54:48 -07:00
Leon
ab35f11077
add FieldNamingPolicy.LOWER_CASE_WITH_DOTS ( #1278 )
2018-04-27 18:50:08 -07:00
Lyubomyr Shaydariv
bdea5b9e99
Removed the executable flag from clearly text files
2018-04-26 10:23:15 +03:00
Inderjeet Singh
4081dbaa6d
Added a test for serialization/deserialization of enum classes with
...
fields
2018-03-17 16:00:46 -07:00
Andrey Mogilev
0aaf5ff408
fix Java9 DateFormat changes ( #1211 )
...
* fix Java9 DateFormat changes
* fix Codacy warnings
2017-12-30 00:44:43 +05:30
Andrey Mogilev
b1fb9ca9a1
fix issue #1107 : resolve element type in wildcard collection types ( #1146 )
...
* fix issue #1107 : resolve element type in wildcard collection types
* fix Codacy warnings
* fix Codacy warnings
2017-09-21 17:50:41 -07:00
Warren Smith
08bbb226f1
Add newBuilder() API ( #1142 )
...
* Add Gson.newBuilder API.
* Remove redundant test.
* Address Codacy comments.
* Reduce visibility of GsonBuilder constructor.
2017-09-20 18:53:10 -07:00
Lyubomyr Shaydariv
7a9fd5962d
Fixed DefaultDateTypeAdapter nullability issue and JSON primitives contract ( #1100 )
...
* Fixed DefaultDateTypeAdapter nullability issue and JSON primitives contract
Regression in:
* b8f616c939
- Migrate DefaultDateTypeAdapter to streaming adapter (#1070 )
Bug reports:
* https://github.com/google/gson/issues/1096 - 2.8.1 can't serialize and deserialize date null (2.8.0 works fine)
* https://github.com/google/gson/issues/1098 - Gson 2.8.1 DefaultDateTypeAdapter is not null safe.
* Fixed DefaultDateTypeAdapter nullability on write
2017-09-17 23:49:13 -07:00
Andrey Mogilev
03a72e752e
Fix StackOverflowError on resolving types with TypeVariable recursion ( #1128 )
...
* Fix StackOverflowError on resolving types with TypeVariable recursion
Sample failing code:
private static class TestType<X> {
TestType<? super X> superType;
}
...
new Gson().getAdapter(TestType.class);
* fix build errors
2017-07-31 10:50:29 -07:00
Mike
ada597e69a
value(double) can write NaN and infinite values when lenient, as value(Number) does ( #1093 )
...
* Added test which shows that lenient JsonWriter fails writing infinite primitive doubles, but does not fail writing boxed doubles, as stated in #1090 .
* Fixed JsonWriter#value(double) to write infinite and NaN values when lenient, as JsonWriter#value(Number) does. (fixes #1090 )
2017-05-31 09:50:44 -07:00
Lyubomyr Shaydariv
b8f616c939
Migrate DefaultDateTypeAdapter to streaming adapter ( #1070 )
2017-05-30 18:12:50 -07:00
Andrey Mogilev
a300148003
Fix StackOverflowError on resolving recursive types by collapsing chains of type bounds ( #1075 )
...
* Fixes StackOverflowError on resolving recursive types.
See Issue #440 , Issue #603 , tests.
* fix 'codacy' coding style warnings
* added copyright header
2017-05-30 17:47:04 -07:00
Lyubomyr Shaydariv
eb27d55f49
Remove helper methods mentioned in the TODO list
2017-04-23 15:54:10 +03:00
inder123
5412f21431
Printing more debugging information to help track an invalid JsonAdapter. ( #1068 )
...
Now the thrown exception carries this information:
java.lang.IllegalArgumentException: Invalid attempt to bind an instance of java.lang.Integer as a @JsonAdapter for com.google.gson.functional.JsonAdapterAnnotationOnClassesTest$D. @JsonAdapter value must be a TypeAdapter, TypeAdapterFactory, JsonSerializer or JsonDeserializer.
2017-04-19 17:08:21 -07:00
Michele Vivoda
9a2421997e
negative zero test and fix ( #1069 )
2017-04-19 14:26:36 -07:00
André Rouél
9e6f2bab20
Fix ArrayIndexOutOfBoundsException when skipping a value with JsonTreeReader #1013 ( #1014 )
2017-02-15 18:41:39 -08:00
Mark Hess
4976e420fc
Add keySet method and test ( #942 )
2016-12-13 22:15:49 -08:00
Egor Neliuba
44cad04a63
Allow deserialization of a Number represented as a String ( #964 )
2016-11-25 23:40:14 -08:00
Jake Wharton
9414b9b3b6
Add static factories for array and parameterized type tokens.
...
These are useful when creating TypeAdapterFactories that delegate to others with more complex types. They also are useful when writing dynamic code that deals with types that cannot be fully reified using the normal subclass technique.
2016-08-12 12:11:57 -04:00
inder123
b2c00a3b02
Merge pull request #873 from google/jwilson.0601.get_delegate_adapter
...
Add support for JsonSerializer/JsonDeserializer in the JsonAdapter annotation
2016-06-14 16:37:14 -07:00
Inderjeet Singh
1f859ec769
addressed code review comments.
2016-06-14 16:34:34 -07:00
Jesse Wilson
c24af30407
Merge pull request #871 from google/jw/tree-json-path
...
Implement JSON Path for JsonTreeReader.
2016-06-09 23:32:24 -07:00
Jake Wharton
c16be41e77
Expose JsonObject size.
2016-06-10 00:46:32 -04:00
Jake Wharton
c2fae85a9f
Implement JSON Path for JsonTreeReader.
2016-06-10 00:14:28 -04:00
Archit Dey
3f8726ecaf
Enhancing the json reader, adding corresponding test case for it
2016-06-02 09:19:43 -04:00
jwilson
2df65502ed
Don't use ThreadLocals for @JsonAdapter factories and getDelegateAdapter().
2016-06-02 00:33:09 -04:00
Inderjeet Singh
45511fdd15
Added support for JsonSerializer/JsonDeserializer for JsonAdapter annotation.
...
JsonAdapter is cached per the type of the JsonAdapter class.
Added a test to ensure JsonAdapter works on fields of parameterized types
Keep track of registered JsonAdapters and JsonAdapterFactorys in ThreadLocal.
2016-06-02 00:08:25 -04:00
Inderjeet Singh
3ff16c30db
Don't use a runtime wrapper if a JsonAdapter annotation is present on a field.
...
This ensures that JsonAdapter annotation works correctly on a primitive field.
This is a potentially backward incompatible change.
2016-05-17 13:30:59 -07:00
Ryan Harter
a851569ab9
Adds getters for config fields.
...
This adds simple getters for certain config fields that would be helpful in custom
TypeAdapters to deal with situations like this:
https://github.com/rharter/auto-value-gson/issues/18
2016-04-26 15:30:01 -04:00
Jake Wharton
59edfc1caf
Add boxed boolean value() overload.
...
When calling value() with a Boolean overload resolution would choose value(boolean) which would throw an NPE on null. The other boxed types are all numbers which would resolve to value(Number) and behave correctly.
2016-04-22 19:52:38 -04:00
Ugljesa Jovanovic
ab40462cc7
Check if class can be instantiated based on class modifiers. If not throw an unsupported operation exception.
2016-04-20 10:43:34 +02:00
Scott Brown
0669ff7fd1
allow unquoted long and integer keys
2016-03-12 11:52:13 -07:00
Inderjeet Singh
1ab73ffd21
incorporated code review feedback by eliminating the stringified type adapter.
2016-02-26 09:25:23 -08:00
Inderjeet Singh
1fa43821e8
removed unneeded null check.
2016-02-25 19:37:07 -08:00
Inderjeet Singh
79a00cd906
incorporated code review feedback. Simplified the code, merged Device and Control and removed unnecessary fields.
2016-02-25 17:38:48 -08:00
Inderjeet Singh
c731abb293
Fixed a regression in Gson 2.6 where Gson caused NPE if the TypeAdapterFactory.create() returned null.
2016-02-25 13:56:42 -08:00
Dongjoon Hyun
aa209fa255
Fix some typos in gson comments.
2016-02-15 14:11:23 -08:00
inder123
8383f5c7fa
Merge pull request #769 from paniko0/master
...
timezones without minutes should be valid according RFC3339
2016-02-02 20:23:52 -08:00
Jake Wharton
c8627c8ab8
Update reader and writer for RFC 7159.
2016-01-18 15:07:33 -05:00
inder123
2ab776b5f5
Merge pull request #771 from google/jw/global-leniency
...
Add setting for leniency on Gson instance.
2016-01-18 14:03:23 -05:00
Jake Wharton
3360c93a76
Add setting for leniency on Gson instance.
...
Add a JsonReader factory (for parity with the JsonWriter one) which provides a configured instance using the Gson settings.
2016-01-18 12:08:11 -05:00
Jerzy Chalupski
23e2916947
Make TypeAdapters created by @JsonAdapter null-safe
2016-01-18 16:41:07 +01:00
Danillo Souza
ed6298c98a
timezones without minutes should are valid according RFC3339
2016-01-11 15:33:55 -02:00
Gorik
bcd52a1fdc
Added ISO8601 complete support for date deserialization
2015-11-23 01:11:41 -05:00
Inderjeet Singh
10cefa49d2
added tests for Properties
2015-11-06 16:17:47 -08:00
Inderjeet Singh
01944b246b
additional tests for PriorityQueue, Vector and Stack.
2015-11-06 16:16:56 -08:00
Inderjeet Singh
47cc34548d
added currency class
2015-11-06 15:41:15 -08:00
Inderjeet Singh
457f53f08f
renamed JavaUtilConcurrentLocksTest to JavaUtilConcurrentAtomicTest
2015-11-06 15:24:15 -08:00
Inderjeet Singh
da4334b8df
fixed typos
2015-11-05 21:43:10 -08:00
Inderjeet Singh
11b26b5256
Added support for AtomicLongArray.
...
Also added tests to ensure LongSerializationPolicy is honored.
2015-11-05 14:15:46 -08:00
Inderjeet Singh
7821b73202
Added support for AtomicInteger, AtomicBoolean, AtomicLong and AtomicIntegerArray.
2015-11-05 10:45:23 -08:00
Inderjeet Singh
fef43b2aaa
Added support to serialize/deserialize ConcurrentMap and ConcurrentNavigableMap.
2015-11-04 21:25:15 -08:00
Inderjeet Singh
e5b3f6368d
updated minimum JDK version to 1.6.
...
Added Overrides for methods implementing an interface.
2015-11-04 18:52:20 -08:00
inder123
fe101c10bc
Merge pull request #719 from google/jwilson_1021_runtime_type_mismatch
...
Fix type hierarchy adapters to do a runtime check.
2015-10-22 09:29:01 -07:00
jwilson
7d1973e6c5
Fix type hierarchy adapters to do a runtime check.
...
Otherwise if we have a type hierarchy adapter for Vehicle, and we
attempt to decode a JSON string as a Car, we get the right exception
if the JSON string is actually decoded as a Truck.
2015-10-21 11:42:30 -04:00
Inderjeet Singh
109915d93a
Implemented support for multiple values for SerializedName annotation.
2015-10-03 02:01:30 -07:00
Inderjeet Singh
3aec173243
small reformatting
2015-09-26 18:02:12 -07:00
Inderjeet Singh
3daf585931
Implemented equals and hashcode for LazilyParsedNumber to fix
...
https://github.com/google/gson/issues/627
2015-09-26 17:58:13 -07:00
Inderjeet Singh
fbb8696e83
Added tests for deserialization of double array
2015-09-01 17:49:34 -07:00
Vladislav Bauer
eb79ec73f0
Add unit tests for constructors from util classes
2015-08-15 05:29:46 +06:00
inder123
0a93efada5
Merge pull request #652 from schlan/fix_turkish_locale_issues
...
Fix issues if runing in an environment with a Turkish locale
2015-08-08 09:10:48 -07:00
inder123
24eec9428b
Merge pull request #671 from ownaginatious/master
...
Support for adding primitives directly to JsonArray instances
2015-07-26 14:17:10 -07:00
Dillon Dixon
5cf82a573f
Added test for nulls
2015-07-23 23:02:46 -07:00
Dillon Dixon
a67ca052a3
Added test for mixed primitives
2015-07-23 23:00:18 -07:00
Dillon Dixon
374e5b0aa5
Added test ovr new DOM functionality
2015-07-23 22:57:32 -07:00
Adam Tanner
457541611c
Replace localhost lookup with static IP to fix test.
...
Calling InetAddress.getLocalHost() will cause a lookup to occur that may
fail with a java.net.UnknownHostException if the system the test is
running on is not configured correctly.
This is often fixed by echoing "127.0.0.1 $HOSTNAME" to /etc/hosts, but
in this case it seems easier to pick a static IP string to avoid the
lookup entirely and prevent false negatives in the test.
2015-07-20 14:03:52 -07:00
Adam Tanner
f7abd59a3b
JsonWriter#jsonValue writes raw JSON values.
...
Add a jsonValue(String value) method that takes a raw JSON string that
can be used to write the string directly to the underlying writer
without modification.
The intended use case for this is when building JSON that contains a
pre-serialized JSON string as a value in an object or array.
2015-07-20 10:56:56 -07:00
Sebastian Chlan
299ee89852
Add tests to demonstrate the issue
...
Run the FieldNamingTest with the JVM options: `-Duser.language=tr
-Duser.region=TR`
2015-06-09 15:12:38 +01:00
Inderjeet Singh
fdaa6b05c4
ensuring that the type field is written by runtime type adapter
2014-12-10 22:57:08 +00:00
Inderjeet Singh
7d96ce8d6d
fixed tests to take care of stackTrace element appearing sometimes
2014-12-10 22:43:44 +00:00
Inderjeet Singh
8d5a41329e
added tests for Throwable. Revised ReflectiveTypeAdapterFactory to ignore self-referencing fields.
2014-11-16 22:55:18 +00:00
Inderjeet Singh
1de2ace065
removed eclipse warnings. updated maven plugins to the latest versions
2014-11-16 20:45:01 +00:00
Inderjeet Singh
60b2370c74
added a test for RuntimeTypeAdapterFactory using JsonAdapter annotation
2014-11-11 22:04:20 +00:00
Inderjeet Singh
e652ec0dd9
revised a test to validate that we can query a delegate adapter from typeadapterfactorie registered in JsonAdapter
2014-11-11 02:02:56 +00:00
Jesse Wilson
d6c8c1e3cf
Fix bugs in getPath() with arrays of objects and arrays of arrays
2014-11-11 01:59:48 +00:00
Jake Wharton
7f8f490fdc
Re-order factories to allow @JsonAdapter on enums which are user-defined types.
2014-11-04 00:59:42 +00:00
Jesse Wilson
ea17ccc651
Restore missing fails.
2014-08-12 21:06:56 +00:00
Jake Wharton
117d8ea68f
Add TypeAdapterFactory support to @JsonAdapter.
2014-08-04 16:58:41 +00:00
Jesse Wilson
125e6d9d3d
Change field annotations to take precedence over registered type adapters.
2014-08-02 18:22:43 +00:00
Inderjeet Singh
f9a302e22a
incorporated code review feedback. Added a test to ensure JsonAdapter validation doesn't carry side-effects to other fields
2014-08-01 02:16:42 +00:00