Commit Graph

46 Commits

Author SHA1 Message Date
Maicol 6c3cf22435
Unnecessary unboxing at JsonPrimitive.getAsBoolean() (#2277) 2022-12-13 09:33:57 -08: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 7f77ad4ff6
Replace `$Gson$Preconditions.checkNotNull` with `Objects.requireNonNull` (#2180)
* Replace $Gson$Preconditions.checkNotNull with Objects.requireNonNull

* Add back checkNotNull
2022-08-22 07:22:32 -07:00
Marcono1234 51a72b463b
Make JsonElement conversion methods more consistent and fix javadoc (#2178)
* Make JsonElement conversion methods more consistent and fix javadoc

* Address some review comments
2022-08-21 13:29:40 -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
Degubi 46d0f58d12 Remove unnecessary explicit else statement 2019-04-05 16:20:06 +02:00
Degubi 3ee3c150ed Remove boolean wrappers in JsonElement 2019-03-31 21:28:12 +02: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
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 172143df7c Removing JsonObject.deepCopy() and JsonArray.deepCopy() 2011-11-12 23:32:44 +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 c4a2291866 Deleted unused fields. 2011-10-02 20:45:26 +00:00
Jesse Wilson de727d8c48 Delete dead code found by coverage 2011-10-01 02:04:48 +00:00
Jesse Wilson 2f0c617d8d Use floating point comparison for all non-integral Number types (such as LazilyParsedNumber) 2011-09-09 08:01:51 +00:00
Inderjeet Singh d70fb90ef7 Added methods to convert to JsonElement in TypeAdapter.
Using lenient mode while working with Gson.
Handling nulls while invoking legacy Gson type adapters.
2011-08-03 02:40:18 +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 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
Inderjeet Singh 824635158c Parsing numbers lazily as a performance enhancement.
This avoids needing to parse number if the equivalent object field doesn't exist.
It also avoids the performance penalty of trying to parse it eagerly as a big decimal, float etc.
2011-04-28 21:57:29 +00:00
Joel Leitch e345feb438 Comments from r821 2011-04-14 18:54:09 +00:00
Joel Leitch c894fb6c23 Default support for BitSet. As well, provide more flexibility on getAsBoolean for a JsonPrimitive. 2011-04-14 02:42:47 +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
Inderjeet Singh 28567508ea Corrected Javadocs to indicate that NumberFormatException gets thrown instead of ClassCastException while attempting to convert a JsonPrimitive to a number. 2011-03-11 00:14:49 +00:00
Jesse Wilson 3d006c90a2 equals & hashCode for subclasses of JsonElement.
Resolves issue 64.
2011-02-15 00:14:20 +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 7a7bbf754c Use JsonReader internally rather than JsonParserJavacc.
For raw parsing (ie. new JsonParser().parse()) the parse time has improved substantially. For example, JsonParserJavacc parsed my 48KiB buzz feed in 4.8ms. JsonReader parses the same feed in 0.9ms.

http://microbenchmarks.appspot.com/run/limpbizkit@gmail.com/com.google.gson.GsonBenchmark/430001
2010-08-27 05:59:18 +00:00
Joel Leitch 93b0008486 Adding restrictions on the JsonElements to disallow Java "null"s. 2009-10-08 22:03:08 +00:00
Inderjeet Singh fdcd3945c5 Fixed issue 147.
Integral values (byte, short, integer, long, BigInteger) are now comparable to each other.
Floating point values (float, double, BigDecimal) are now comparable to each other.
2009-09-23 18:54:01 +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 c13fc568c7 Fixed indentation and simplified equals method as per code review comments on r419 2009-08-18 18:07:25 +00:00
Inderjeet Singh 64172d1dac Added support to serialize and deserialize array of java.lang.Object when the content is a primitive type. 2009-07-27 23:24:23 +00:00
Inderjeet Singh f418ab69a2 Implementing hashcode and equals for JsonPrimitives as value type equality. 2009-04-03 21:24:38 +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 ea79cd6812 Allow booleans and number to be deserialized into a "String" field/object. 2008-12-14 04:42:16 +00:00
Joel Leitch 5ae7e1f803 Adding new convenience method to JsonObject for adding Booleans and Characters. 2008-11-30 23:36:29 +00:00
Joel Leitch b506183d94 Move isPrimitiveOrString() method from ObjectNavigator to JsonPrimitive. 2008-11-27 00:40:31 +00:00
Joel Leitch 0c98c2f8d1 More lenient parsing of Numbers and Booleans. Basically, can deserialize properly formatted stringr representations of numbers and booleans. 2008-11-20 19:40:12 +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 57d1f32de5 moved gson as a project under trunk 2008-09-01 03:13:32 +00:00