Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gson.fromJson(..., TypeToken) overloads #1700

Merged
merged 12 commits into from Sep 19, 2022

Commits on May 21, 2020

  1. 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")
    Marcono1234 committed May 21, 2020
    Copy the full SHA
    ab6284c View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2020

  1. 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.
    Marcono1234 committed Jun 10, 2020
    Copy the full SHA
    789bb16 View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2020

  1. 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.
    Marcono1234 committed Sep 2, 2020
    Copy the full SHA
    3b64053 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    04fbb6d View commit details
    Browse the repository at this point in the history
  3. 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.
    Marcono1234 committed Sep 2, 2020
    Copy the full SHA
    224db11 View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2022

  1. Copy the full SHA
    8d010d5 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    b38ef2c View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    17b40f8 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    853d9f5 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2022

  1. Copy the full SHA
    c34ba6c View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    43ebe28 View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2022

  1. Remove fromJson(JsonReader, Class) again

    As noticed during review adding this method is source incompatible.
    Marcono1234 committed Sep 19, 2022
    Copy the full SHA
    6ad87f0 View commit details
    Browse the repository at this point in the history