Marcono1234
dc28951fa7
Change target Java version to 7 ( #2043 )
...
* Change target Java version to 7
* Document Gson requirements
* Add package-info.java for `stream` package
2021-12-31 07:20:29 -08:00
Marcono1234
6ffcdf3029
Fix Javadoc warnings and errors ( #2040 )
2021-12-26 15:30:21 -08:00
Éamonn McManus
6e06bf0d89
Fix for an ArrayIndexOutOfBoundsException.
...
The `fillBuffer` method changes `pos`, so it is incorrect to cache
its previous value.
2021-11-11 14:12:44 -05: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
530cb74470
Fix javadoc doclint HTML warnings ( #1653 )
2020-02-17 14:46:15 -08:00
Degubi
9bf25c2eb6
Refactor prefix array & loop logic, use if-s instead ( #1505 )
2019-10-04 13:45:06 -07:00
David Maplesden
3958b1f78d
Prefer writing chars instead of strings of length one ( #1576 )
...
This results in a noticeable performance improvement with most writer
implementations (including BufferedWriter).
2019-09-18 10:33:49 -07:00
Degubi
bac26b8e42
Optimize array copies
2019-03-05 12:12:04 -05: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
sourabh gupta
5848096f3e
Size allocation of StringBuilder ( #1047 )
...
Size allocation of StringBuilder
2017-05-24 15:49:09 -07:00
Eric Cochran
3270e8d972
Remove need for synthetic accessor methods.
2017-04-22 17:32:59 -07:00
Michele Vivoda
9a2421997e
negative zero test and fix ( #1069 )
2017-04-19 14:26:36 -07: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
Mohammad Yasir
9c30b0e203
Incorporating code review suggestions
2017-02-17 07:25:23 +05:30
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
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
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
Scott Brown
0669ff7fd1
allow unquoted long and integer keys
2016-03-12 11:52:13 -07:00
Jake Wharton
c8627c8ab8
Update reader and writer for RFC 7159.
2016-01-18 15:07:33 -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
Jake Wharton
7a1c94f986
Remove synthetic accessors from being generated.
2015-12-27 01:39:19 -05:00
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
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
Jesse Wilson
d6c8c1e3cf
Fix bugs in getPath() with arrays of objects and arrays of arrays
2014-11-11 01:59:48 +00:00
Jesse Wilson
fbc7e69c81
Implement JsonPath in JsonReader.
2014-07-31 05:17:54 +00:00
Joel Leitch
70f9280cb6
Remove usage of StringPool as it appears to slow things down and avoid Java String intern for the common cases.
2013-04-08 18:36:23 +00:00
Joel Leitch
84201c015f
Do not peek during a "skipValue" if a value has already been peeked.
2013-01-14 18:38:46 +00:00
Jesse Wilson
084047d80b
Reintroduce string pooling in JsonReader.
...
This makes Hotspot slower. From my before/after measurements using ParseBenchmark, times in microseconds:
TWEETS: 350 -> 370 (+6%)
READER_SHORT: 77 -> 76 (-1%)
READER_LONG: 870 -> 940 (+8%)
But it makes Dalvik faster by a greater margin. These before/after measurements use times in milliseconds:
TWEETS: 25 -> 20 (-20%)
READER_SHORT: 5.6 -> 4.7 (-16%)
READER_LONG: 52 -> 47 (-10%)
It's a net win because we're saving a greater fraction of time, and because we're helping the platform that needs the most help. We're paying microseconds on Hotspot to gain milliseconds on Dalvik.
2012-09-10 16:13:33 +00:00
Jesse Wilson
8df7209074
Fix cut & paste issue in JsonToken Javadocs.
...
Fixes issue 463.
2012-09-02 21:29:30 +00:00
Jesse Wilson
b3b919770b
Change number parsing to use one big loop. This changes it to return JsonToken.STRING for very long (>8k digits) numbers.
2012-09-02 20:12:19 +00:00
Jesse Wilson
3920d95fac
rename peekedInteger to peekedLong
2012-09-02 17:46:02 +00:00
Jesse Wilson
8daf3aaeb4
Inline position computation. This is uglier but faster.
2012-08-28 03:52:18 +00:00
Jesse Wilson
46b73632b0
Fix a bug where we weren't reading enough characters when a BOM was encountered.
2012-08-28 01:48:25 +00:00
Jesse Wilson
980796005f
Use a conventional for loop in nextQuotedValue() to make hotspot's job easier.
2012-08-27 04:42:39 +00:00
Jesse Wilson
bdf2cac6d4
Replace switch with if/else when processing whitespace. If/else is faster!
2012-08-27 04:17:29 +00:00
Jesse Wilson
b0a172944a
More number parsing improvements.
2012-08-27 03:17:41 +00:00
Jesse Wilson
448063dde1
Fix a goof in number parsing.
2012-08-27 03:07:20 +00:00
Jesse Wilson
4c2980e6ff
Fix a bug in integer parsing.
2012-08-27 02:34:52 +00:00
Jesse Wilson
c7cb503cdb
Restore fast skips.
...
document api ns linear runtime
TWEETS GSON_STREAM 397568 =========
TWEETS GSON_SKIP 300058 =======
READER_SHORT GSON_STREAM 76632 =
READER_SHORT GSON_SKIP 57796 =
READER_LONG GSON_STREAM 894690 =====================
READER_LONG GSON_SKIP 565114 =============
2012-08-27 01:17:50 +00:00
Jesse Wilson
085856c128
Don't leave the JsonReader in an invalid state if nextInt(), nextDouble() or nextLong() fails. We now save a reference to the string before we parse it, and keep that referenced value if parsing fails.
2012-08-26 22:06:57 +00:00
Jesse Wilson
e7bfd0c97d
Promote JsonReader2 to be the main JsonReader implementation.
2012-08-26 19:34:46 +00:00
Jesse Wilson
553fa6b742
Prepare to replace JsonReader with JsonReader2
2012-08-26 19:33:49 +00:00
Jesse Wilson
b96d2d9837
Support non-execute prefixes.
2012-08-26 19:31:06 +00:00
Jesse Wilson
97cb326ad2
Delete an old version of the rewritten JsonReader
2012-08-26 04:04:22 +00:00
Jesse Wilson
46b4346505
Get JsonReader2 to the point that it's passing most tests.
...
Still missing:
- non-execute prefixes
- rolling back 'pos' when a double fails to parse
- octal prefix failures
2012-08-26 04:02:09 +00:00
Jesse Wilson
c5c65ba626
Add an experimental rewrite of JsonReader.
...
The motivating difference is that JsonReaderV2 tries to read each character at most once. This means that when it reads literals, it also attempts to decode them to a keyword (true/false/null) or a number.
This change also _doesn't_ read strings until demanded to do so. This should permit streaming access to strings down the road.
This code is not yet complete, nor is has it been properly optimized. And the implementation is also quite a mess! It is a work in progress.
2012-08-25 04:31:56 +00:00
Jesse Wilson
35c13173b0
Switch on ints rather than enums in JsonReader.
...
Using enums was triggering this Android bug:
http://code.google.com/p/android/issues/detail?id=36349
2012-08-14 21:32:18 +00:00