Commit Graph

41 Commits

Author SHA1 Message Date
Marcono1234
6b9db2e449
Add Gson.fromJson(..., TypeToken) overloads (#1700)
* Add Gson.fromJson(..., TypeToken) overloads

Previously only Gson.fromJson(..., Type) existed which is however not
type-safe since the generic type parameter T used for the return type is
not bound.
Since these methods are often used in the form
  gson.fromJson(..., new TypeToken<...>(){}.getType())
this commit now adds overloads which accept a TypeToken and are therefore
more type-safe.

Additional changes:
- Fixed some grammar mistakes
- Added javadoc @see tags
- Consistently write "JSON" in uppercase
- More precise placement of @SuppressWarnings("unchecked")

* Add to Gson.fromJson javadoc that JSON is fully consumed

The newly added documentation deliberately does not state which exception
is thrown because Gson.assertFullConsumption could throw either a
JsonIOException or a JsonSyntaxException.

* Remove unnecessary wrapping and unwrapping as TypeToken in Gson.fromJson

Since the actual implementation of Gson.fromJson is TypeToken based, the
TypeToken variant overloads are now the "main" implementation and the other
overloads delegate to them.
Previously the Type variant overloads were the "main" implementation which
caused `TypeToken.getType()` followed by `TypeToken.get(...)` when the
TypeToken variant overloads were used.

* Trim source code whitespaces

* Fix Gson.fromJson(JsonReader, Class) not casting read Object

To be consistent with the other Gson.fromJson(..., Class) overloads the
method should cast the result.

* Replace User Guide link in Gson documentation

* Remove more references to fromJson(..., Type)

* Extend documentation for fromJson(JsonReader, ...)

* Replace some TypeToken.getType() usages

* Address feedback; improve documentation

* Remove fromJson(JsonReader, Class) again

As noticed during review adding this method is source incompatible.
2022-09-19 06:47:11 -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
Éamonn McManus
a4290c52e0 Update CHANGELOG.md with 2.9.1 changes.
Update version numbers in documentation (2.9.0 -> 2.9.1).
2022-07-31 14:43:17 -07:00
Marcono1234
3f1d4fb65f
Document Map serialization in user guide (#2138)
* Document Map serialization in user guide

* Improve user guide formatting and update links

* Address review feedback
2022-06-27 14:59:43 -07:00
Éamonn McManus
241044d709 Update CHANGELOG.md with 2.9.0 changes.
Update version numbers in documentation (2.8.9 -> 2.9.0).
2022-02-11 11:39:48 -08:00
Éamonn McManus
466ca72916 Update version number in UserGuide.md and proto/pom.xml. 2021-10-31 06:57:33 -07:00
Z
9484297fbb
update UserGuide.md (#1954)
Id Class does not have get method, we should new a instance.
2021-09-07 08:00:11 -07:00
Éamonn McManus
03be835914 Update change log, and version numbers in documentation. 2021-08-20 10:02:13 -07:00
Éamonn McManus
45c0bd96f0 Update user guide and change log to reflect 2.8.7 release. 2021-05-24 16:39:52 -07:00
Simon Legner
1a9469a8c5
doc(UserGuide): mention TypeAdapters class (#1685) 2020-05-02 01:01:44 -07:00
inder123
188c6dbce6
Updated to use Gson 2.8.6 2019-10-04 12:09:03 -07:00
Prempal Singh
0409a2ecab Fix typo in UserGuide (#1572) 2019-09-18 10:39:14 -07:00
Marcono1234
f07fa51200 Change URLs from http to https (#1521)
* Change URLs from http to https

* Changed github.io to javadoc
2019-05-07 16:27:45 -07:00
Tomy Jaya
ab0821c83e Fix wrong reference in Versioning Support example (#1482) 2019-03-07 00:26:22 -08:00
Jeremy W. Sherman
aa1a34eb5e
Display null-handling details as sublist
Indent the details of null handling.

Comparing against the [old, Google Sites user guide][gsites] shows that the two items following the "handles nulls correctly" item are intended as a sublist under that item.

[gsites]: https://sites.google.com/site/gson/gson-user-guide#TOC-Finer-Points-with-Objects
2018-10-26 11:12:00 -04:00
Karan Kumar
86ade21078 Change 'compile' to 'implementation' 2018-08-21 21:12:12 +01:00
inder123
5184e717ce
Updated User Guide for 2.8.5 2018-05-21 20:14:49 -07:00
inder123
f77615ecff
2.8.4 2018-05-01 11:17:35 -07:00
inder123
3bc566b226
version 2.8.3 2018-04-27 15:42:25 -07:00
Elliotte Rusty Harold
28344d861d Clarify handling of non-object omitted fields (#1169)
While deserializing, a missing entry in JSON results in setting the corresponding field in the object to its default value: null for object types, zero for numeric types, and false for booleans.
2017-10-28 16:41:25 -07:00
inder123
e38a6ce60d minor typo 2017-09-29 15:47:51 -07:00
inder123
b46b04d7a3 ToC edit for gradle 2017-09-29 15:46:53 -07:00
inder123
35b3b7596d Added gradle section 2017-09-29 15:45:51 -07:00
inder123
a8f7acd618 Update UserGuide.md 2017-09-19 18:57:02 -07:00
Matthew Haughton
3fdedd405b UserGuide formatting fix (#1045)
* UserGuide formatting fix

* UserGuide formatting fixes
2017-03-21 11:14:47 -07:00
inder123
791236ac79 Fixed https://github.com/google/gson/issues/958 2016-11-14 21:21:24 -08:00
Jake Wharton
a786628318 Version is actually 2.8.0 2016-11-08 11:17:33 -05:00
Greg Koblanski (melquiades)
9a2d8a20a4 Update gson version used in the Maven example 2016-11-08 16:13:31 +00:00
inder123
28c8e1c29b Updated to 2.7 2016-06-14 17:07:51 -07:00
Nth Circle
1bffde09ed Typo
Changed "Serialiers" to "Serializers"
2016-05-07 20:48:54 -07:00
zzz40500
71ee0e3759 Documentation Error
String anotherStr = gson.fromJson("[\"abc\"]", String.class); => String[] anotherStr = gson.fromJson("[\"abc\"]", String[].class);
2016-04-24 01:36:52 +08:00
Ryan Scheidter
4f031a4e78 UserGuide Grammar Corrections 2016-04-05 09:20:14 -05:00
inder123
956f59fd59 2.6.2 2016-02-26 19:03:37 -08:00
Jonathan Paugh
bad5cc8047 Collapse bullets into a paragraph
The section entitled "Collections Limitations" contains 3 bullets, but one semantic point.

Make this point in a paragraph instead of a bullet list.
2016-02-22 15:30:29 -06:00
jwilson
0ae177fefb Update docs for Gson 2.6.1. 2016-02-11 23:17:00 -05:00
Misha Brukman
883fbd0a16 Added language annotations to code blocks.
This enables GitHub to do proper syntax highlighting, thus improving the
readability of multi-line code blocks. As a result, some changes were required
to make the code blocks syntactically correct, since they're actually parsed by
language-aware parsers; primarily, this meant inserting comments.
2015-11-27 18:40:04 -05:00
Misha Brukman
b4ca41aafe Docs fixes: markdown, links, formatting.
* Removed extra spacing after bullets in list
* Removed extra blank lines; fixed indentation
* Fixed all links (including examples) to code.google.com to use github.com
  instead; deep links to code.google.com redirect to top-level GitHub project
  page, thus rendering them useless
* Removed extra strings in Markdown link targets
* Fixed capitalization and grammar
* Added more code formatting
2015-11-27 17:13:19 -05:00
Misha Brukman
14e53cf7d4 Added code formatting; removed HTML tags.
Also fixed minor grammar issues.
2015-11-27 15:45:21 -05:00
inder123
f642395949 added maven instructions 2015-11-24 17:55:40 -08:00
inder123
594cb33b5f Fixed ToC 2015-11-24 13:57:20 -08:00
inder123
4e1c352261 Imported User Guide from Google Sites 2015-11-24 13:46:45 -08:00