question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[JSON] Pluggable JSON parsing to remove GSON dependency

See original GitHub issue

I am interested in creating a pluggable JSON parsing system to allow for replacing GSON with another parser, such as Moshi that is popular for Android apps to help reduce the app size footprint of the sentry Android library. From my testing sentry-android ends up adding ~1.5MB to the app size, but sentry-android-core without the NDK bundle only adds about 200-400KB to the download size where a significant percent of that is the GSON library.

Is there any appetite for a contribution that would refactor to allow a different json parser for Android such as Moshi? This would be a pretty large change, so I want to have a discussion before I begin.

Some changes (but probably not all) that I see this involving:

  • refactoring gson code into its own module.
  • creating a sentry-android-moshi-extension module or similar to encapsulate the moshi, or other parsing code. One particular point about moshi is that it is in kotlin so non test code would be in kotlin, in this module.
  • Create a system so the default sentry package was GSON as it is today and an extension package could be added for moshi or other parsers that would exclude gson.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
nwadamscommented, Jun 16, 2021

to help reduce the app size footprint of the sentry Android library

Given this motivation, it would be fair to assume if we drop the dependency to Gson (and read/write json directly without reflection) this issue would no longer be needed?

I’m asking as we are considering redoing the serialization in order to avoid reflection (to all known protocol types) and a dependency to Gson.

Yeah. That would solve the issue for us completely since no large external libraries would be used that have duplicate functionality

1reaction
nwadamscommented, Apr 26, 2021

Got it. Thank you for the context @marandaneto and @bruno-garcia

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove dependency on GSON internal API #304 - GitHub
JSON class depends on ISO8601Utils from GSON internal API. The utils class is sued to parse sql dates from string and render to...
Read more >
How to parse JSON in Java - Stack Overflow
java's built in JSON libraries are the quickets way to do so, but in my experience GSON is the best library for parsing...
Read more >
Gson - How to parse JSON - Mkyong.com
import java.lang.reflect.Modifier; Gson gson = new GsonBuilder() .excludeFieldsWithModifiers(Modifier.STATIC) .
Read more >
Gson User Guide - Google Sites
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to...
Read more >
Parsing JSON using GSON within a Maven project in IntelliJ ...
... soup: I show how to create a Maven project within IntelliJ IDEA, bring in the GSON library, and use that to parse...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found