Navigate:
~$GSON0.1%

Gson: Java JSON serialization and deserialization library

Reflection-based Java library for JSON object conversion.

LIVE RANKINGS • 02:15 PM • STEADY
OVERALL
#459
46
DEVELOPER TOOLS
#100
8
30 DAY RANKING TREND
ovr#459
·Devel#100
STARS
24.3K
FORKS
4.4K
7D STARS
-28
7D FORKS
-1
See Repo:
Share:

Learn more about Gson

Gson is a Java library for converting between Java objects and JSON format. It uses reflection-based serialization to work with arbitrary Java objects, including pre-existing classes without access to source code. The library handles generic types, nested objects, and inheritance hierarchies through its type adapter system. Gson is commonly used in server-side Java applications, though the maintainers recommend alternative libraries for Android development due to reflection incompatibility with code obfuscation.

Gson

1

Zero-Annotation Object Mapping

Works with arbitrary Java objects without requiring source code modifications or annotations. Serializes third-party libraries and legacy classes directly, unlike frameworks that mandate interface implementation or metadata declarations.

2

Full Generic Type Preservation

Maintains complete type information for parameterized collections and complex generic hierarchies during serialization. TypeToken API captures runtime generic types that Java's erasure normally discards, enabling type-safe deserialization of List<String> versus List<Integer>.

3

Reflection-Based Introspection

Uses runtime reflection for automatic object traversal without code generation or compilation steps. Simplifies integration and supports dynamic class structures, though incompatible with aggressive obfuscation tools like R8 or ProGuard in Android release builds.


import com.google.gson.Gson;

class User {
    String name;
    String email;
}

Gson gson = new Gson();
User user = new User();
user.name = "John Doe";
user.email = "john@example.com";

String json = gson.toJson(user);
// {"name":"John Doe","email":"john@example.com"}


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers