Commit Graph

1286 Commits

Author SHA1 Message Date
Inderjeet Singh
f649e05141 [maven-release-plugin] prepare release gson-parent-2.8.5 2018-05-21 20:08:09 -07:00
joel-leitch
4c685b21a8 Private constructor (#1324)
* Adding private constructors on Util classes

* Remove obsolete step
2018-05-21 20:04:22 -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
Inderjeet Singh
446a3bff8d [maven-release-plugin] prepare for next development iteration 2018-05-01 11:06:37 -07:00
Inderjeet Singh
9fbebdf990 [maven-release-plugin] prepare release gson-parent-2.8.4 2018-05-01 11:06:25 -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
941363f14c
Added gradle/Idea support (#1302) 2018-04-30 09:54:24 -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
Inderjeet Singh
7dd379ffe1 [maven-release-plugin] prepare for next development iteration 2018-04-27 15:34:26 -07:00
Inderjeet Singh
4ed639e882 [maven-release-plugin] prepare release gson-parent-2.8.3 2018-04-27 15:34:15 -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
8445689e4d Java 9 support: use Unsafe-based reflection in Java 9+ (#1218)
* Java 9 support: use Unsafe-based reflection in Java 9+

fixes "illegal reflective access" warnings and exceptions

* fix Codacy warnings

* improve code quality based on PR review

* improve code quality based on PR review

* fix Codacy warning

* improve code quality based on PR review

* inlined createReflectionAccessor method
2018-01-04 00:38:50 +05:30
Andrey Mogilev
0aaf5ff408 fix Java9 DateFormat changes (#1211)
* fix Java9 DateFormat changes

* fix Codacy warnings
2017-12-30 00:44:43 +05:30
Anirudh Ramanan
3bf1967c0a Optimised the create() call for Excluder TypeAdapterFactory (#1199)
* optimized the create() method, excludeClass used to get called two times, changed it to one

* fixed the create() method, and added support to disableAnonymousAndLocalClassSerialization

* peek only once

* enable anonymous and local class serialization

* bugfix

* removed the method, will raise it as a separate PR
2017-12-28 06:03:45 +05:30
michaelsavich
7ddac52748 Java 9 module (#1179)
* Add module-info.java

* Exclude module-info.java by default
2017-12-26 21:58:19 +05:30
Trung Do
855f0493d0 Fix a small typo (#1183) 2017-10-31 11:43:24 -07:00
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
Inderjeet Singh
c0b50ba3a3 [maven-release-plugin] prepare for next development iteration 2017-09-19 18:41:44 -07:00
Inderjeet Singh
d90f63dc88 [maven-release-plugin] prepare release gson-parent-2.8.2 2017-09-19 18:41:34 -07:00
Nels Beckman
ddcd6aea7d Update fromJson Javadoc. (#1151)
For the string-based fromJson() method, mention that the result will be null if the given string is empty.
2017-09-18 00:08:22 -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
Warren Smith
d9cc7bc60b Make GsonBuilder.create() factory order idempotent. (#1141) 2017-08-14 08:56:16 -07:00
Tom Magnusson
68cf8fdc95 fix typo in ConstructorConstructor exception 2017-08-03 09:28:31 -04: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
Igor Mysak
ee691fba43 fix javaDoc (#1122) 2017-07-21 10:12:25 -07:00
inder123
3090a7ed2a Made deepCopy public (#1091)
* Made deepCopy public

* since 2.8.2
2017-05-31 10:33:37 -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
Inderjeet Singh
0aaef0fd1b [maven-release-plugin] prepare for next development iteration 2017-05-30 18:38:01 -07:00
Inderjeet Singh
3e74bb47d1 [maven-release-plugin] prepare release gson-parent-2.8.1 2017-05-30 18:37:51 -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
sourabh gupta
5848096f3e Size allocation of StringBuilder (#1047)
Size allocation of StringBuilder
2017-05-24 15:49:09 -07:00
James Carman
f7012e5865 Adding maven-bundle-plugin. (#1071) 2017-05-24 15:25:50 -07:00
Jake Wharton
b58de2f4ae Merge pull request #1073 from lyubomyr-shaydariv/public-tojson
Remove helper methods mentioned in the TODO list
2017-05-02 10:37:11 -04:00
Lyubomyr Shaydariv
eb27d55f49 Remove helper methods mentioned in the TODO list 2017-04-23 15:54:10 +03:00
Eric Cochran
3270e8d972 Remove need for synthetic accessor methods. 2017-04-22 17:32:59 -07: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
Mohammad Yasir
92b52d25d8 Performance fix to avoid reflection-based initialization of null key surrogate 2017-04-12 16:11:20 -04:00
sourabh gupta
441fa98735 Simplified access of getSimpleName (#1042)
* Simplified access of getSimpleName

instead of calling getClass.getSimpleName() that will check too many conditions inside , we can make it as final String and use it directly.

* Simplified access of getSimpleName

making string as static

* Simplified access of getSimpleName

Code Review changes
2017-03-20 14:25:52 -07:00
Jesse Wilson
423ff04a75 Merge pull request #1037 from guptasourabh/master
elimiating code overhead
2017-03-18 15:34:09 -04:00
guptasourabh
8101ab74e9 list addition optimization (#1038)
* list addition optimization

* Optimized imports

Optimized imports
2017-03-16 21:16:38 -07:00
Sourabh Gupta
d0e70bcdbf elimiating code overhead 2017-03-15 22:41:42 +05:30
guptasourabh
fd37cf1d0d JsonArray with capacity in constructor (#1033)
JsonArray with capacity in constructor
2017-03-12 19:59:41 -07:00
Anirudh Ramanan
9e44d60b83 Eliminating code overhead
* calculating size of the list once in case of loops, avoided creation of string builder object if the length type argument is 0
* replaced null check boilerplate code with nullSafe()
2017-03-01 11:13:56 -05:00
Mohammad Yasir
4644837207 Incorporating the review comments. While more than 1 charachter might be read from the buffer the output will have only one escaped charachter. 2017-02-17 11:54:30 +05:30
Jesse Wilson
2d072bae3a Merge pull request #1015 from yasirmhd/master
Memory optimisation in JsonReader
2017-02-16 22:58:16 -05:00
Mohammad Yasir
9c30b0e203 Incorporating code review suggestions 2017-02-17 07:25:23 +05:30
André Rouél
9e6f2bab20 Fix ArrayIndexOutOfBoundsException when skipping a value with JsonTreeReader #1013 (#1014) 2017-02-15 18:41:39 -08:00
Mohammad Yasir
ba4643134a Removing unused variable 2017-02-16 03:00:02 +05:30
Mohammad Yasir
410b4a8c62 Optimizing for memory 2017-02-16 02:51:02 +05:30
BloodShura
9d8d7a43e1 All JsonElement::getAsJsonXXX methods now include the JSON string on thrown exception's message 2017-02-07 22:04:22 -02:00
Martin Lind
08c7bffba0 Fix for #957 (#994) 2017-01-11 10:38:33 -08:00
Yutaro Iino
9e5e4ac630 Add missing comma in toString() 2016-12-21 00:10:42 +09:00
Mark Hess
4976e420fc Add keySet method and test (#942) 2016-12-13 22:15:49 -08:00
Kevin Most
5f73666404 Update JsonAdapter documentation (#976)
Include mention of JsonDeserializer and JsonSerializer.
2016-12-11 22:37:55 -08:00
Egor Neliuba
44cad04a63 Allow deserialization of a Number represented as a String (#964) 2016-11-25 23:40:14 -08:00
jwilson
14c8c1a82b [maven-release-plugin] prepare for next development iteration 2016-10-26 23:01:41 -07:00
jwilson
e9ead40302 [maven-release-plugin] prepare release gson-parent-2.8.0 2016-10-26 23:01:37 -07:00
Inderjeet Singh
688f918a35 Added @Documented to Gson annotations.
This is useful since it shows the JSON format for a class which the user of that class should typically know.
2016-09-15 18:24:21 -07: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
testcenter
193349f4aa made nullSafe wrapper of JsonAdapter optional 2016-06-28 09:18:03 +02:00
Inderjeet Singh
0a29fcf859 [maven-release-plugin] prepare for next development iteration 2016-06-14 16:52:32 -07:00
Inderjeet Singh
9722b00372 [maven-release-plugin] prepare release gson-parent-2.7 2016-06-14 16:52:28 -07:00
Inderjeet Singh
687ddb319e Preparing 2.7-SNAPSHOT to cut the 2.7 release. 2016-06-14 16:39:19 -07: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
inder123
ebad966efd Merge pull request #870 from google/jw/reader-location
Consolidate location and path rendering for exceptions.
2016-06-09 15:26:10 -07:00
Jake Wharton
ecaa57114f Consolidate location and path rendering for exceptions. 2016-06-09 18:02:36 -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
943c674276 Removed ThreadLocal for activeJsonAdapterClasses 2016-06-02 00:08:25 -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
Jesse Wilson
bb451eac43 Merge pull request #832 from google/831
Ensuring that JsonAdapter annotation works correctly for primitive fi…
2016-05-17 17:26:52 -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
Inderjeet Singh
61f83d6309 Replaced a JDK 1.7 specific method with its JDK 1.6 equivalent. 2016-05-17 01:03:00 -07:00
Baschdl
c414b368e1 Corrected documentation, copy&paste error 2016-05-12 14:47:03 +02:00
Jake Wharton
371aff7ce4 Switch default Queue implementation to ArrayDeque.
Now that we require Java 1.6 or newer this much more efficient implementation can be used as the default.
2016-04-27 00:37:28 -04:00
Jake Wharton
8537c8932f Optimize list allocation for every reflective field.
The common cases (no @SerializedName and a single-value @SerializedName) now use a specialized one-element collection. Cases with alternate names use a much more space efficient ArrayList which is exactly sized.

This is also a performance win for adapter initialization since an index-based loop was used on the returned type for which LinkedList is not suited for.
2016-04-27 00:28:51 -04: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
Jesse Wilson
0f66f4fac4 Merge pull request #829 from ionspin/master
Check if class can be instantiated based on class modifiers. Fix for #817
2016-04-22 06:47:08 -10: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
gavlyukovskiy
966de9e60d fixed throwing RuntimeException instead of JsonIOException 2016-04-15 21:00:59 +03:00
Scott Brown
9c4f352320 minor javadoc fix ... @code block not treated as html 2016-04-08 19:34:05 -06:00
Inderjeet Singh
34d7521d95 moved the JsonSerializationContext/JsonDeserializationContext fields to where they are used.
Also moved TreeTypeAdapter to internal.bind package for potential use in JsonAdapterAnnotationFactory.
2016-03-28 14:46:02 -07:00
Scott Brown
0669ff7fd1 allow unquoted long and integer keys 2016-03-12 11:52:13 -07:00
qwwdfsad
31dcfa3ad6 More appropriate usage of null key surrogate in Gson#getAdapter for backward compatibility 2016-03-05 02:08:26 +03:00
qwwdfsad
c5611847a3 Gson synchronized map replaced with concurrent hash map 2016-03-05 00:28:25 +03:00
Inderjeet Singh
416ddb101d [maven-release-plugin] prepare for next development iteration 2016-02-26 18:31:14 -08:00
Inderjeet Singh
fe62b04148 [maven-release-plugin] prepare release gson-parent-2.6.2 2016-02-26 18:22:26 -08:00
Inderjeet Singh
0dfa28ac3e previous mvn release:prepare failed but updated GitHub anyway. Fixing that. 2016-02-26 18:19:41 -08:00
Inderjeet Singh
607bcaaf9d [maven-release-plugin] prepare for next development iteration 2016-02-26 18:14:54 -08: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
Sean Bright
4eff1a855f Restore OSGi manifest headers
Commit 2016e95 removed the necessary MANIFEST.MF headers for Gson to
resolve in an OSGi environment. This patch restores them.
2016-02-24 09:14:09 -05:00
Dongjoon Hyun
aa209fa255 Fix some typos in gson comments. 2016-02-15 14:11:23 -08:00
jwilson
796b4ca26d [maven-release-plugin] prepare for next development iteration 2016-02-11 22:53:04 -05:00
jwilson
3c9b9af0a1 [maven-release-plugin] prepare release gson-parent-2.6.1 2016-02-11 22:52:59 -05:00
jwilson
85722329db [maven-release-plugin] prepare for next development iteration 2016-02-11 13:03:12 -05:00
jwilson
b8220eb195 [maven-release-plugin] prepare release gson-parent-2.6 2016-02-11 13:03:10 -05:00
jwilson
2016e9553e Simplify Gson poms.
A lot of the configuration in these poms has been taken over by improvements
to the Maven release plugin.
2016-02-11 12:56:33 -05: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
Psidium
61f58baaf9 fix typo in JsonArray docs 2016-01-12 11:02:42 -02:00
Danillo Souza
ed6298c98a timezones without minutes should are valid according RFC3339 2016-01-11 15:33:55 -02:00
inder123
1f803bd37d Merge pull request #761 from google/jw/nuke-synthetics
Remove synthetic accessors from being generated.
2015-12-27 14:08:23 -05:00
Jake Wharton
7a1c94f986 Remove synthetic accessors from being generated. 2015-12-27 01:39:19 -05:00
inder123
59a8fb5c5e Update pom.xml 2015-12-14 16:48:49 -08:00
Inderjeet Singh
2b4ac2334e [maven-release-plugin] prepare for next development iteration 2015-11-23 19:32:33 -08:00
Inderjeet Singh
d7d064feb8 [maven-release-plugin] prepare release gson-parent-2.5 2015-11-23 19:32:26 -08:00
Gorik
d86dfdec7c Removed unused code in ISO8601Utils 2015-11-23 01:21:41 -05:00
Gorik
bcd52a1fdc Added ISO8601 complete support for date deserialization 2015-11-23 01:11:41 -05:00
inder123
e48c780389 Merge pull request #733 from google/java_util_additional_classes
Supported Currency and added additional tests for Vector, Stack and Properties.
2015-11-17 17:57:59 -08:00
Inderjeet Singh
c935f89b23 Added the cause to Assertions 2015-11-16 09:16:23 -08:00
Inderjeet Singh
05b17f9271 Adding details in the throw exception on a missing field. 2015-11-16 09:12:23 -08: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
caef762530 added factory fields for consistency 2015-11-05 14:03:51 -08:00
Inderjeet Singh
cc54e4dbdd made methods static 2015-11-05 10:46:54 -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
79e1c669ed Linking to JDK 6 javadocs 2015-11-04 18:55:23 -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
Roman Mazur
3b1671dde9 Fix javadoc of SerializedName
In #699 the approach was changed but docs were left for the first implementation.
2015-10-04 19:56:02 +03:00
Inderjeet Singh
d0ee733c96 [maven-release-plugin] prepare for next development iteration 2015-10-03 17:38:26 -07:00
Inderjeet Singh
80c13447ed [maven-release-plugin] prepare release gson-parent-2.4 2015-10-03 17:38:17 -07:00
Inderjeet Singh
d1883b5e5b added relativePath to avoid warning about incorrect parent path 2015-10-03 17:37:14 -07:00
Inderjeet Singh
109915d93a Implemented support for multiple values for SerializedName annotation. 2015-10-03 02:01:30 -07:00
Jesse Wilson
3361030766 Merge pull request #705 from google/627
Implemented equals and hashcode for LazilyParsedNumber to fix
2015-09-27 17:25:04 -04:00
Inderjeet Singh
96b2ada79a incorporated code review feedback: optimized LazilyParsedNumber.equals/hashcode() by utilizing the fact that value is never passed as null. 2015-09-27 13:58:01 -07:00
dushyant
2ecce94494 typo 2015-09-27 16:01:27 +05:30
Inderjeet Singh
1e9004403c Fixed javadoc for JsonWriter as reported in
https://github.com/google/gson/issues/623
2015-09-26 18:10:00 -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
Jake Wharton
e81f3eba27 Expose newJsonWriter wrapper instead of just options.
This is more future proof to ensure that consumers holding on to TypeAdapters for efficiency can always encode JSON in the same way as if the Gson instance was used directly.
2015-09-26 19:19:38 -04:00
Jake Wharton
31f80d8659 Merge pull request #700 from google/jwilson_0907_serializenulls_accessor
Expose serializeNulls with an accessor.
2015-09-07 22:44:05 -04:00
jwilson
ff2c8f8e8b Expose serializeNulls with an accessor.
Useful for frameworks that build on Gson.
2015-09-07 22:31:43 -04:00
Inderjeet Singh
1bf62f0214 updated maven plugin versions to latest 2015-09-07 12:02:45 -07:00
Dorvaryn
618343fd1b Clarify the fact that the behaviour of getDelegateAdapter depends on registration order. 2015-09-03 18:15:24 +01:00
Inderjeet Singh
fbb8696e83 Added tests for deserialization of double array 2015-09-01 17:49:34 -07:00
Jesse Wilson
87717662f7 Merge pull request #689 from vbauer/util-classes
Add unit tests for constructors from util classes
2015-08-14 20:42:31 -04:00
Vladislav Bauer
eb79ec73f0 Add unit tests for constructors from util classes 2015-08-15 05:29:46 +06:00
Michael Evans
64d74db8ae Add METHOD target for use with AutoValue's abstract property methods 2015-08-14 14:08:56 -04:00
Inderjeet Singh
0c4ae01836 Updated Gson Javadoc to indicate thread-safety. 2015-08-10 19:34:07 +05:30
inder123
2ee680a645 Revert "Add a JSR-305 @ThreadSafe annotation to the Gson class" 2015-08-10 19:31:18 +05:30
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
Lars Vogel
37d00c268d Readme points to the new homepage at Github 2015-07-29 18:45:24 +02: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
inder123
d805f22166 Merge pull request #669 from adamtanner/inet-address-test-failure
Replace localhost lookup with static IP to fix test.
2015-07-26 14:13:32 -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
Dillon Dixon
d8c12a727f Fixed accidental duplication of null elements 2015-07-23 21:18:01 -07:00
Dillon Dixon
6960ebc776 Updated JsonArray to support adding primitives directly via an overloaded "add(...)" method rather than having to always do "add(new JsonPrimitive(...))" 2015-07-23 20:44:04 -07:00
Adam Tanner
2b67815808 Change references to Google Code to Github. 2015-07-20 14:31:39 -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
Stefan Ferstl
82edd57205 Add a JSR-305 @ThreadSafe annotation to the Gson class
- Add an optional dependency to com.google.code.findbugs:jsr305.
  The optional scope is used in order to avoid introducing a new
  transitive dependency to the jsr305 library. This is fine because the 
  @ThreadSafe annotation has only a documentary purpose and it is not
  retained at runtime.
- Annotate the Gson class as @ThreadSafe

Fixes Issue #613
2015-07-13 18:34:38 +02:00
Jake Wharton
032847976c There is no I/O writing to a StringWriter. 2015-06-17 22:01:17 -04:00
Sebastian Chlan
6e57df7e96 FieldNamingPolicy: Use Locale.ENGLISH to be locale insensitive 2015-06-09 15:25:16 +01: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
1d9e86e27c fixed extras build 2014-12-04 22:07:13 +00:00
Inderjeet Singh
33e74101e5 javadocs for 2.3.1 2014-11-20 10:17:53 +00:00
Inderjeet Singh
c3d17e39f1 [maven-release-plugin] prepare for next development iteration 2014-11-20 09:09:32 +00:00
Inderjeet Singh
eba6825a38 [maven-release-plugin] prepare release gson-2.3.1 2014-11-20 09:08:22 +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
b6a625fb6c fixed issue 469 by adding a TypeAdapterFactory for throwables that ignores cause if it is self-referencing 2014-11-16 22:25:23 +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
84e3442eb0 Fixed issue 582 2014-11-12 23:35:36 +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
Inderjeet Singh
f2591b6664 adjusted factory finding code to take into account non-present factories 2014-11-10 23:15:31 +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
6580921f9d Use a version range that works with Maven 3.0.4.
Fixes issue 588.
2014-09-16 14:40:54 +00:00
Jesse Wilson
ea17ccc651 Restore missing fails. 2014-08-12 21:06:56 +00:00
Inderjeet Singh
c6eced6d87 javadocs for 2.3 2014-08-12 00:01:30 +00:00
Inderjeet Singh
85e2d1901c [maven-release-plugin] prepare for next development iteration 2014-08-11 23:35:34 +00:00
Inderjeet Singh
cf894f3d58 [maven-release-plugin] prepare release gson-2.3 2014-08-11 23:35:29 +00:00
Inderjeet Singh
192e32d430 updated maven pom for Java8 2014-08-11 23:33:42 +00:00
Jake Wharton
c5dc3b791b Correct JsonElement javadoc exception references. 2014-08-09 06:14:12 +00:00
Jake Wharton
f4185289f6 Correct TypeAdapterFactory reference in its Javadoc. 2014-08-09 05:35:33 +00:00
Jake Wharton
f1f838cf20 Favor post-Gingerbread instantiation mechanism.
pre-Gingerbread is now a small subset of the Android OS distribution and is constantly shrinking toward zero.
2014-08-09 05:32:50 +00:00
Jesse Wilson
6a3e83a741 Javadoc for TypeAdapterFactory in @JsonAdapter. 2014-08-05 15:00:15 +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
Jesse Wilson
fbc7e69c81 Implement JsonPath in JsonReader. 2014-07-31 05:17:54 +00:00
Inderjeet Singh
80bbf4a85a revised JsonArray.set() method to return the JsonElement. (thanks Buchholz Bastian for catching that!) 2014-07-04 17:31:43 +00:00
Inderjeet Singh
b9578a4d7e renamed JsonArray.has() to JsonArray.contains() 2014-07-04 02:03:34 +00:00
Inderjeet Singh
94e21eca21 renamed JsonArray.contains() to has() to be consistent with JsonObject.has() 2014-07-03 17:31:07 +00:00
Inderjeet Singh
06282a4d13 Fixed issue code.google.com/p/google-gson/issues/detail?id=353 by adding set method in JsonArray 2014-07-02 18:30:17 +00:00
Inderjeet Singh
9bbdcac5a8 Fixed issue code.google.com/p/google-gson/issues/detail?id=353 by adding remove and contains methods in JsonArray 2014-07-02 18:21:36 +00:00
Jesse Wilson
c6752fc47a Fix inverted docs in ExclusionStrategy. 2014-06-04 04:30:19 +00:00
Jesse Wilson
a411a766f7 Leitch --> Wilson ! 2014-05-23 05:43:39 +00:00
Inderjeet Singh
14ba59fa88 code review fixes. Moved getFirstArgument() method from $Gson$Types to GsonTypesTest. 2014-05-19 17:34:25 +00:00
Inderjeet Singh
b373c20136 Fixed issue 552 by documenting when fromJson returns null. 2014-03-29 23:28:52 +00:00
Inderjeet Singh
c53e255105 Fixed typo as mentioned in issue 565 2014-03-26 18:07:59 +00:00
Inderjeet Singh
edf66083e6 renamed @Adapt to @JsonAdapter 2014-03-26 17:59:54 +00:00
Inderjeet Singh
7f6a096030 renamed JsonAdapter annotation to Adapt annotation. 2014-03-09 23:08:54 +00:00
Inderjeet Singh
6e8d3cd65e Created threadsafe implementation of JsonAdapter invocation. Also fixed a bug where runtime generated typeadapters were being carried over from a toJson/fromJson call to the next. 2014-03-09 23:00:53 +00:00
Inderjeet Singh
e280ffd7e2 Fixed broken test to ensure that a field JsonAdapter annotation supersedes the class JsonAdapter annotation.
Added a map in Gson to keep track of TypeAdapters which are generated by Gson.
2014-03-09 08:36:24 +00:00
Inderjeet Singh
0922af5be6 removed invalid imports 2014-03-09 08:23:05 +00:00
Inderjeet Singh
67af0dd8f8 Added javadoc comment in JsonAdapter explaining the usage for fields.
Added a (broken) test the ensure a field annotation for JsonAdapter supersedes a class annotation.
2014-03-09 08:21:06 +00:00
Inderjeet Singh
f88eee094c removed some eclipse warnings 2014-03-09 07:33:08 +00:00
Inderjeet Singh
eaaa2a1b4f added functional tests for applying JsonAdapter annotation on Fields. 2014-03-09 07:31:02 +00:00
Inderjeet Singh
b9998e511f deleted support for the magic GSON_TYPE_ADAPTER field 2014-03-09 07:30:37 +00:00
Inderjeet Singh
bf549f0589 Added support for JsonAdapter annotation on fields 2014-03-09 07:28:04 +00:00
Inderjeet Singh
67d512ee7d Created a JsonAdapter annotation that can be applied to classes to indicate their TypeAdapter. 2014-03-08 22:37:19 +00:00
Inderjeet Singh
7c97ac2944 Updated Gson version to 2.3-SNAPSHOT since this is a new feature.
Added support for a magic field GSON_TYPE_ADAPTER in a class. This adapter is automatically invoked if present.
The field must be present in the class (not in any super-type), and must be strongly typed as TypeAdapter<T>.
2014-03-08 20:08:13 +00:00
Inderjeet Singh
b2a9d872db deleted redundant and invalid precondition. 2014-03-08 19:33:24 +00:00
Inderjeet Singh
c3d0f200b3 Fixed a bug where an inner static class was incorrectly marked as non-static while creating parameterized types. 2014-03-08 19:12:24 +00:00
Inderjeet Singh
b52f692ffa update various maven plugin versions 2014-03-08 17:30:15 +00:00
Inderjeet Singh
eb817e307f added snapshot repository in pom.xml 2013-09-03 17:49:15 +00:00
Inderjeet Singh
c235aa0c1b updated the id of the sonatype nexus staging repository. 2013-09-02 19:27:44 +00:00
Inderjeet Singh
2b95a4822b added distribution management section to pom 2013-09-01 23:42:08 +00:00
Jesse Wilson
1840466704 Fix a nasty bug where elements in LinkedHashTreeMap could be dropped.
The underlying problem is that the doubleCapacity function would drop the parent links when all nodes ended up on the same side in a doubling. This was caused by the fact that the AvlIterator was destructive on parent nodes, and we weren't putting them back together with the AvlBuilder. This removes an incorrect optimization and fixes the problem.

Also move LinkedHashTreeMap back into main from test.
2013-05-14 21:43:20 +00:00
Joel Leitch
d2b660570e 2.2.4 JavaDoc. 2013-05-13 21:45:29 +00:00
Joel Leitch
6f19060e14 [maven-release-plugin] prepare for next development iteration 2013-05-13 21:36:45 +00:00
Joel Leitch
b378548c5c [maven-release-plugin] prepare release gson-2.2.4 2013-05-13 21:36:39 +00:00
Joel Leitch
8834343861 Moving broken class to "test" package for now and disabling broken test. 2013-05-13 21:01:33 +00:00
Joel Leitch
2d5cab1b7b Fix hashing in LinkedHashTreeMap, but it still does not work :( 2013-05-13 20:40:07 +00:00
Joel Leitch
3f4bc4cd10 Remove unused import 2013-05-13 20:38:35 +00: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
Joel Leitch
f29d5bc37b Create a LinkedTreeMap based on the LinkedHashTreeMap; however, removed all the hashing from it as resorted to a single tree. The insertion order is still preserved. 2013-05-03 16:11:16 +00:00
Joel Leitch
7c9fd53c78 Fix test that expects an exception to fail if no exception is thrown 2013-05-03 15:34:58 +00:00
Joel Leitch
b88e0e9395 Test to expose edge doubling and rehashing bug in LinkedHashTreeMap. 2013-05-03 15:13:30 +00:00
Joel Leitch
8e8bb9c688 Added test for comments inside a string value. 2013-04-14 21:36:47 +00:00
Inderjeet Singh
93041211d1 2.2.3 javadocs 2013-04-12 21:51:58 +00:00