Skip to content

Feature request: without gson #24

Closed

Description

@alosdev

Hi maintainers,

would it be possible to get a version of this library without gson? My current application has no reference to this and I don't want to bloat it. Why not just using pure json.org.
If you would be fine with this, I also could create a PR with these changes.

Best
Hasan

Activity

  1. changed the title [-]without gson[/-] [+]Feature request: without gson[/+] on Jun 11, 2018
  2. lbalmaceda commented on Jun 28, 2018

    @lbalmaceda
    Contributor

    Hey @alosdev! I missed this one.
    We decided to use Gson since it's a wide used JSON library in the Android environment and compared to Jackson it provides less friction and better performance for simple JSON payloads. For this SDK in particular it only needs to deserialize simple JWTs body's.

    If I understand your concern correctly, you suggest we parse the input manually instead of requiring an extra dependency. This is doable because the public API does not expose any Gson class. However, it was easier to go with the well-known trusted JSON library that most of the Android apps use. Because this library is made specifically for Android in mind (in opposition to https://github.com/auth0/java-jwt/), we find that using Gson is fine. If the size of your application is important to you, running Proguard before preparing the package is a standard practice all developers should follow. With the right set of ignore rules only the classes used by this library would be included in the final APK, thus the size would be lower.

    That said, I'm curious about what you have in mind and how that improves this library in terms of performance.

  3. alosdev commented on Jul 2, 2018

    @alosdev
    Author

    Hi @lbalmaceda,

    thanks for your response. You can always have a discussion regarding different libraries. I didn't want to start this one here, btw. we are using Moshi. So having a different one mocks me. As you already wrote yourself, that you have simple JWT body, which is not large. Therefore giving the burden of a not visible dependency for your users is quite high. The performance gain, in this case, is really neglectable. Also, you don't do it with every request. So my dream would be one without gson or have a pluggable architecture like retrofit. :)

    Best
    Hasan

  4. lbalmaceda commented on Jul 2, 2018

    @lbalmaceda
    Contributor

    Opening the JSON deserializer to the user looks like overkill for such a simple library to me today, but we might consider it when we add signature verification in the near future. I'll leave this in our backlog to discuss with the team.

    When you say "one without Gson", do you have an implementation in mind that doesn't use any dependency or you mean use Moshy? 😆

    Cheers

  5. alosdev commented on Jul 2, 2018

    @alosdev
    Author

    json deserializer wouldn't be a big issue, I hope ;)
    Moshi would be nice, but I think, that several other people will complain. so it would be best to go to plain json.org

  6. lbalmaceda commented on Jul 31, 2019

    @lbalmaceda
    Contributor

    We decided against using a different JSON serialization dependency. As mentioned in the second comment, out intent is to make a simple android-focused library to decode JWTs. Gson has good performance on Android contexts for this case. Running Proguard would remove any unused code from your library's dependencies (including this one) if size is an issue. Every production build should run Proguard as recommended by Google.

  7. renaudcerrato commented on Sep 3, 2020

    @renaudcerrato

    I'm bumping this one: GSON is considered as deprecated by 2 of 3 maintainers. See also here.

  8. emartynov commented on Aug 8, 2023

    @emartynov

    Found this and would suggest a modular SDK - where the core would have an interface to decode and json and there will be a couple of default additional sdks that would use popular json libraries to implement it.

  9. arekolek commented on Jan 29, 2026

    @arekolek

    We decided to use Gson since it's a wide used JSON library in the Android environment

    I'll just leave this here:

    https://github.com/google/gson
    Important
    Gson is not a recommended library for interacting with JSON on Android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions