Commit Graph

54 Commits

Author SHA1 Message Date
Éamonn McManus
c1da2d7070
Add @CanIgnoreReturnValue as appropriate to Gson methods. (#2369)
This annotation indicates that return value of the annotated method does
not need to be used. If it is _not_ present on a non-void method, and if
Error Prone's `CheckReturnValue` is active, then calling the method
without using the result is an error. However, we are not enabling
`CheckReturnValue` by default here.

Also update some code that does ignore return values, so that the
returned value is used, if only by assigning it to an unused variable.
2023-04-10 10:50:25 -07:00
Éamonn McManus
2ce6a6106c [maven-release-plugin] prepare release gson-parent-2.10.1 2023-01-06 07:42:31 -08:00
Doug Hoard
ceb3b8747e
Added JsonObject method isEmpty() (#2233)
* Added isEmpty()

* Fixed Javadoc typo

* Changed test to use assertTrue() and assertFalse()
2022-11-13 12:58:30 -08:00
Éamonn McManus
9efdfad33c [maven-release-plugin] prepare release gson-parent-2.10 2022-10-24 17:33:34 -07:00
Marcono1234
4f948dd482
Automatically replace version references on release:prepare (#2212)
* Automatically replace version references on `release:prepare`

* Specify encoding and improve placeholder replacements

* Add `since $next-version$` for `JsonArray.asList` and `JsonObject.asMap`
2022-10-24 17:26:43 -07:00
Marcono1234
954d526af4
Add JsonArray.asList and JsonObject.asMap view methods (#2225)
* Add `JsonArray.asList` and `JsonObject.asMap` view methods

* Address review comments
2022-10-16 12:30:49 -07:00
Marcono1234
28609089fa
Add Javadoc since tags for previously added elements (#2211) 2022-10-01 15:58:26 -07:00
Marcono1234
847d7f6638
Improve documentation (#2193)
* Improve JsonElement subclasses javadoc and add tests

* Slightly improve JsonSerializer and JsonDeserializer javadoc

* Improve ReflectionAccessTest failure message

* Improve documentation regarding field and class exclusion
2022-09-09 07:32:55 -07:00
Marcono1234
5e1005ea27
Disallow JsonObject Entry.setValue(null) (#2167)
* Disallow JsonObject Entry.setValue(null)

* Adjust comments in JsonObjectTest
2022-08-18 13:10:43 -07:00
Marcono1234
246270e02c
Convert null to JsonNull for JsonArray.set (#2170)
* Convert null to JsonNull for `JsonArray.set`

All other methods perform the same implicit conversion.

* Mention null handling in JsonObject documentation
2022-08-06 09:57:00 -07:00
Marcono1234
0b6a7bf7d9
Deprecate JsonElement constructor (#1761)
* Deprecate JsonElement constructor

Creating custom JsonElement subclasses is discouraged.

* Improve test and documentation

* Improve JsonTreeReaderTest, adjust deprecation comments
2022-08-04 10:32:30 -07:00
Marcono1234
4dda4ec5ba
Use diamond operator when creating generic instances (#2104) 2022-04-17 15:27:21 -07:00
Degubi
8bf2949c29 Remove object based constructors, remove some internal stuff 2019-03-11 10:53:31 -04:00
inder123
3090a7ed2a Made deepCopy public (#1091)
* Made deepCopy public

* since 2.8.2
2017-05-31 10:33:37 -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
Mark Hess
4976e420fc Add keySet method and test (#942) 2016-12-13 22:15:49 -08:00
Jake Wharton
c16be41e77 Expose JsonObject size. 2016-06-10 00:46:32 -04: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
af6aa5f782 Use the LinkedHashTreeMap instead of LinkedTreeMap and delete the LinkedTreeMap version. 2013-04-04 21:31:23 +00:00
Joel Leitch
14f16e2d0c Adding Red-Black Tree implementation and tying it into the Gson bindings. 2012-10-11 03:15:49 +00:00
Jesse Wilson
411c5c0b50 Follow up on r1197 and make deepCopy package-private. We don't want to use protected because some of the classes are non-final and protected shows up in the Javadocs. 2012-09-03 23:30:27 +00:00
Inderjeet Singh
a973837dd4 made deepCopy protected to eliminate it from the public API for now.
It will be in the subsequent release.
2012-09-03 08:34:37 +00:00
Jesse Wilson
9c4b23b39a JsonObject.deepCopy() for Gson. 2012-08-21 01:19:43 +00:00
Jesse Wilson
4c629347da Only support string keys in string map. This rev passed all 655 applicable map tests in the Guava collections test suite. 2012-03-11 17:34:46 +00:00
Jesse Wilson
ad3489f557 First steps to StringMap, an alternative to LinkedHashmap. 2012-03-11 13:54:41 +00:00
Jesse Wilson
172143df7c Removing JsonObject.deepCopy() and JsonArray.deepCopy() 2011-11-12 23:32:44 +00:00
Jesse Wilson
9cf579ef01 Use Streams instead of Escaper.
Fixes issue 345.
2011-07-12 23:50:00 +00:00
Jesse Wilson
f74dffc6fd Add deepCopy to JsonArray and JsonObject.
Resolves issue 301.
2011-06-17 21:46:28 +00:00
Inderjeet Singh
61b9a2cb17 Moved field creation to the field declaration to avoid inadvertent change from LinkedHashMap to something else. 2011-05-30 09:01:45 +00:00
Inderjeet Singh
e79bcde8bf Using JsonNull.INSTANCE instead of JsonNull.createJsonNull() method 2011-05-25 16:55:57 +00:00
Inderjeet Singh
c8bd121db2 Renamed $Preconditions to $Gson$Preconditions and $Types to $Gson$Types.
Marked the two private classes in $Types as final.
2011-04-06 00:26:57 +00:00
Inderjeet Singh
feb9617bf0 Incorporated comments from r726 2011-04-04 22:09:51 +00:00
Jesse Wilson
4efb133b4a bling bling
Prefix internal classes with $ to prevent them from interfering with IDE's auto import functionality.
2011-03-29 21:24:26 +00:00
Joel Leitch
861e047a62 Create an "internals" package for classes that we do not want to share, but is needed across multiple pacakges.
As well, move non-Gson specific classes, such as Preconditions, to this new "internals" package.
2011-03-21 22:30:35 +00:00
Joel Leitch
279c0e87ed Update Precondition checks and have it throw a NPE instead. 2011-03-16 07:23:44 +00:00
Jesse Wilson
3d006c90a2 equals & hashCode for subclasses of JsonElement.
Resolves issue 64.
2011-02-15 00:14:20 +00:00
Inderjeet Singh
f4098b5cf7 implemented feedback from r585 2010-11-05 22:18:35 +00:00
Inderjeet Singh
2b1f3eec15 Removed a bunch of unused code and unnecessary else statements. 2010-09-28 13:42:43 +00:00
Jesse Wilson
7e1e4eab07 Remove the constraint that map keys mustn't be the empty string.
See bug 227.
2010-08-28 05:02:33 +00:00
Joel Leitch
5bffa1f679 Fix for Issue 178. 2010-08-21 06:50:52 +00:00
Joel Leitch
fffb204cee Removed import for java.util.Map.Entry. 2009-10-09 18:10:43 +00:00
Joel Leitch
6d60a7db1d Fixed comments from r486. 2009-10-09 00:36:22 +00:00
Joel Leitch
93b0008486 Adding restrictions on the JsonElements to disallow Java "null"s. 2009-10-08 22:03:08 +00:00
Joel Leitch
50eb582657 Ensure that the JsonElement.toString() will always generate valid JSON (even when control characters/whitespace characters are used). 2009-09-23 18:28:03 +00:00
Inderjeet Singh
149604f0be Made author tags consistent across the public api. 2009-04-01 17:03:31 +00:00
Joel Leitch
6a80791f13 Code cleanup and some minor performance fixes. 2009-01-20 01:36:54 +00:00
Joel Leitch
09720f28cf Incorporated changes from r307 code review 2008-12-18 20:21:05 +00:00
Joel Leitch
a18a751240 Share the same JsonNull instance with the Gson code. 2008-12-18 20:14:29 +00:00
Joel Leitch
11a29b63b0 Implemented suggested changes from r324 code review. 2008-12-02 23:41: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