Commit Graph

20 Commits

Author SHA1 Message Date
Maicol be87c3fd0e
Port Junit test to Truth in the package `com.google.gson` of the module `gson` (#2299)
* Add the Truth dependency

* Port Junit test to Truth in the package `com.google.gson` of the module `gson`

* Replace the `assertThat(e.getMessage()).isEqualTo(...)"` with `assertThat(e).hasMessageThat().isEqualTo(...)`

* Minor fixes
2023-01-17 07:59:10 -08:00
Maicol 1a2170b99c
Port tests from JUnit 3 to JUnit 4 (#2294)
* Port tests from JUnit 3 to JUnit 4

* Port tests from JUnit 3 to JUnit 4

* Add `@Test` above `@Ignore`
2022-12-22 06:04:16 -08:00
Marcono1234 2d01d6a20f
Make `Object` and `JsonElement` deserialization iterative (#1912)
* Make Object and JsonElement deserialization iterative

Often when Object and JsonElement are deserialized the format of the JSON
data is unknown and it might come from an untrusted source. To avoid a
StackOverflowError from maliciously crafted JSON, deserialize Object and
JsonElement iteratively instead of recursively.

Concept based on 51fd2faab7
But implementation is not based on it.

* Improve imports grouping

* Address review feedback
2022-06-22 17:42:19 -07:00
Degubi c5a3f21fba Refactor JsonParser to statics & fix tests 2019-04-15 22:35:10 -04:00
Joel Leitch 14f16e2d0c Adding Red-Black Tree implementation and tying it into the Gson bindings. 2012-10-11 03:15:49 +00:00
Inderjeet Singh 6575cdebca When EOF is encountered prematurely, Streams.parse() (and JsonParser) now throw JsonSyntaxException. 2012-07-02 18:36:54 +00:00
Inderjeet Singh 582b0a0c9c Fixed issue 443 by relying on Streams.parse() to return a JsonNull on empty documents and throw a JsonParseException otherwise. 2012-06-30 18:48:11 +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 b649f2768c Support unquoted single word strings in lenient mode!
Fixes issue 282.
2011-02-10 01:36:27 +00:00
Joel Leitch 56344cf067 Remove duplicate test. 2010-11-16 22:18:28 +00:00
Joel Leitch 0a3f5fa801 Required strings to be quoted even in lenient mode.
As far as Inderjeet and I can tell, this is consistent with Gson 1.5.
2010-11-16 22:14:40 +00:00
Joel Leitch 32afd1a4e4 Fixing parsing of unquoted strings to be (somewhat) consistent with previous versions of Gson. The difference with this version is that Gson will throw a more specific exception rather than JsonParseException. 2010-11-10 02:02:57 +00:00
Jesse Wilson ffdf0e7012 Fix some test problems.
JsonWriter was using suboptimal escape characters for newlines etc: unicode escapes rather than \x escapes.

JsonObjectTest was banning empty and whitespace-only keys. These values are permitted as of r585.
2010-09-02 00:10:26 +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 0e17041c8b Added another test to JsonParserTest. 2009-09-23 19:21:09 +00:00
Joel Leitch b0f50bb4be Return a "JsonNull" object for empty whitespace input into the JsonParser. 2009-09-23 19:00:05 +00:00
Inderjeet Singh 0127891081 Added a new API method in JsonParser to allow reading of multiple JSON objects on a stream asynchronously. 2009-05-08 22:22:34 +00:00
Joel Leitch c8cb35e025 Adding copyright statement to JsonParserTest. 2009-04-01 16:56:40 +00:00
Inderjeet Singh 2034090b15 Changed version to 1.3
Made JsonParser.parse a non-static method.
2009-03-31 17:53:23 +00:00
Inderjeet Singh 2c7cc620d4 Exposed API for JsonParser and added methods to Gson to deserialize from a parse tree. 2009-02-04 01:56:28 +00:00