Commit Graph

15 Commits

Author SHA1 Message Date
Éamonn McManus
9578583eff
Small tweaks to fix Error Prone warnings. (#2227)
* Small tweaks to fix Error Prone warnings.

* Add another suppression.
2022-10-24 10:28:25 -07:00
Marcono1234
5269701679
Improve JsonReader.skipValue() (#2062)
* Fix JsonReader.skipValue() not behaving properly at end of document

JsonReader implementation erroneously reset `peeked` to PEEKED_NONE;
JsonTreeReader threw ArrayIndexOutOfBoundsException.

* Fix JsonReader.skipValue() not behaving properly at end of array and object

For JsonReader this caused an IllegalStateException (in the past it caused
JsonReader to get stuck in an infinite loop); for JsonTreeReader it only
popped the empty iterator but not the JsonArray or JsonObject, which caused
peek() to again report END_ARRAY or END_OBJECT.

* Only have JsonReader.skipValue() overwrite path name when name was skipped

This improves the JSON path when the value for a property was skipped and
before the subsequent property (or the end of the object) getPath() is called.

* Address feedback; improve test coverage

Co-authored-by: Éamonn McManus <emcmanus@google.com>
2022-10-10 07:51:36 -07:00
Marcono1234
a4bc6c17d7
Fix JsonTreeReader throwing wrong exception type for non-finite doubles (#1782)
Follow-up for #1767
2022-08-08 06:39:29 -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
710a76c8b8
Fix JsonReader.hasNext() returning true at end of document (#2061) 2022-01-27 15:59:50 -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
Marcono1234
ba96d53bad
Fix missing bounds checks for JsonTreeReader.getPath() (#2001)
There are situations where the stack of JsonTreeReader contains a JsonArray
or JsonObject without a subsequent Iterator, for example after calling peek()
or nextName().
When JsonTreeReader.getPath() is called afterwards it therefore must not
assume that a JsonArray or JsonObject is always followed by an Iterator.

The only reason why this never caused an ArrayIndexOutOfBoundsException in
the past is because the stack has an even default size (32) so it would just
have read the next `null`.
However, if the stack had for example the default size 31, a user created a
JsonTreeReader for 16 JSON arrays nested inside each other, then called 15
times beginArray(), followed by peek() and getPath() the exception would
occur.
2021-10-25 12:14:41 -07:00
Marcono1234
bda2e3d16a
Improve number strategy implementation (#1987)
* Fix GsonBuilder not copying number strategies from Gson

* Improve ToNumberPolicy exception messages
2021-10-11 16:14:47 -07:00
Simon Guerout
66fd2acdcf Fix formatting 2021-08-30 09:57:08 -07:00
Simon Guerout
ac14b4c197 Make the nextJsonElement more robust
Add test cases
2021-08-30 09:57:08 -07:00
Simon Guerout
62a9702385 Improve the speed of the JSON_ELEMENT TypeAdapter when the object graph has already been turned into a JsonElement 2021-08-30 09:57:08 -07:00
Degubi
bac26b8e42 Optimize array copies 2019-03-05 12:12:04 -05:00
André Rouél
9e6f2bab20 Fix ArrayIndexOutOfBoundsException when skipping a value with JsonTreeReader #1013 (#1014) 2017-02-15 18:41:39 -08:00
Jake Wharton
c2fae85a9f Implement JSON Path for JsonTreeReader. 2016-06-10 00:14:28 -04:00
Inderjeet Singh
8ee2c24f61 renamed JsonElementReader to JsonTreeReader 2011-12-03 02:37:27 +00:00