OSS TanbouSign in with GitHub

serialize and deserialize Java objects to JSON without requiring annotations on every model

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
24,233
Primary language
Java
License
Apache-2.0
Repository last updated
Oct 1, 2026
On this page

Overview

Gson is a Java library for converting objects to JSON and JSON back to Java objects. It supports existing classes and generic types and can customize representation with TypeAdapters. Version 2.14.0 adds built-in java.time adapters and reduces reflective access to JDK internals.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Convert Java objects with toJson and fromJson

Gson can serialize and deserialize existing classes without requiring source changes or annotations on every model.

Sources: [1]

Handle generic and custom representations with TypeToken and TypeAdapter

TypeToken carries generic type information while custom adapters provide explicit mappings for special formats and third-party classes.

Sources: [1][3]

Use built-in java.time adapters in 2.14.0

Adapters for classes such as Instant and Duration avoid the prior reliance on reflective access to private JDK fields and the corresponding --add-opens workaround.

Sources: [2]

Best fit

Fits lightweight JSON mapping in Java applications

It works well for API payloads, configuration, and straightforward object mapping when schema or code generation is not required.

Sources: [1]

Before adoption

The project is in maintenance mode

The README says existing bugs will be fixed but large new features are unlikely, which matters when choosing it for long-lived new designs.

Sources: [1]

Review reflection behavior on Android and non-Java JVM languages

The project does not recommend Gson for Android because R8/ProGuard optimization can conflict with reflection, and Kotlin-specific nullability and default-constructor semantics are not explicitly supported.

Sources: [1][3]

Official sources

  1. [1]Gson 2.14.0 README(2026-10-04)
  2. [2]Gson 2.14.0 release(2026-10-04)
  3. [3]Gson troubleshooting guide(2026-10-04)
  4. [4]Gson Apache 2.0 license(2026-10-04)
Supplemental curator note

Gson is in maintenance mode. Upstream does not recommend it for Android because reflection interacts poorly with R8/ProGuard, so compare code-generation alternatives for new Android projects.

Try it in 3 steps

  1. 1

    Create a minimal Maven project for Gson 2.14.0

    Pin Gson to 2.14.0 in an isolated Maven project. Gson supports Java 8+, while this sample compiles with Java 17.

    mkdir -p gson-demo/src/main/java/demo && printf '%s\n' '<project xmlns="http://maven.apache.org/POM/4.0.0">' '<modelVersion>4.0.0</modelVersion>' '<groupId>demo</groupId><artifactId>gson-demo</artifactId><version>1.0.0</version>' '<properties><maven.compiler.release>17</maven.compiler.release></properties>' '<dependencies><dependency><groupId>com.google.code.gson</groupId><artifactId>gson</artifactId><version>2.14.0</version></dependency></dependencies>' '</project>' > gson-demo/pom.xml
  2. 2

    Create a small object-to-JSON example

    Use a plain Java class with no Gson annotations and serialize it with toJson.

    printf '%s\n' 'package demo;' 'import com.google.gson.Gson;' 'public class Main {' ' static class User { String name = "Ada"; int id = 42; }' ' public static void main(String[] args) { System.out.println(new Gson().toJson(new User())); }' '}' > gson-demo/src/main/java/demo/Main.java
  3. 3

    Compile and verify the JSON output

    Resolve Gson 2.14.0, compile the project, and confirm that the Java object is serialized to JSON.

    cd gson-demo && mvn -q compile dependency:build-classpath -Dmdep.outputFile=cp.txt && java -cp "target/classes:$(cat cp.txt)" demo.Main
Check the official README

Growth

Growth trends · Last 30 days

24,233 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
12
Open PRs
109

Development activity is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data
Stars
24,233
Forks
4,489
Watchers
739
Open issues
224
Contributors
175
Owner type
Organization
Primary language
Java
License
Apache-2.0
Repository last updated
Oct 1, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?