{"id":3546,"url":"https://github.com/google/gson","last_synced_at":"2025-11-12T21:18:52.783Z","repository":{"id":29011727,"uuid":"32538871","full_name":"google/gson","owner":"google","description":"A Java serialization/deserialization library to convert Java Objects into JSON and back","archived":false,"fork":false,"pushed_at":"2025-05-01T03:19:44.000Z","size":13692,"stargazers_count":23694,"open_issues_count":338,"forks_count":4331,"subscribers_count":732,"default_branch":"main","last_synced_at":"2025-05-05T13:53:59.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-19T18:21:20.000Z","updated_at":"2025-05-05T13:15:08.000Z","dependencies_parsed_at":"2023-01-16T23:15:50.436Z","dependency_job_id":"f915ad4f-f1e4-4382-8146-d860ca1c8d2e","html_url":"https://github.com/google/gson","commit_stats":{"total_commits":1920,"total_committers":173,"mean_commits":"11.098265895953757","dds":0.675,"last_synced_commit":"78caa5e69ec1c914bd0edbe888d0c10681cb8e91"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/gson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759423,"owners_count":21959765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:44.559Z","updated_at":"2025-11-12T21:18:52.778Z","avatar_url":"https://github.com/google.png","language":"Java","readme":"# Gson\n\nGson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.\nGson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of.\n\nThere are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes; something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.\n\n\u003e [!NOTE]\\\n\u003e Gson is currently in maintenance mode; existing bugs will be fixed, but large new features will likely not be added. If you want to add a new feature, please first search for existing GitHub issues, or create a new one to discuss the feature and get feedback.\n\n\u003e [!IMPORTANT]\\\n\u003e Gson's main focus is on Java. Using it with other JVM languages such as Kotlin or Scala might work fine in many cases, but language-specific features such as Kotlin's non-`null` types or constructors with default arguments are not supported. This can lead to confusing and incorrect behavior.\\\n\u003e When using languages other than Java, prefer a JSON library with explicit support for that language.\n\n\u003e [!IMPORTANT]\\\n\u003e Gson is not a recommended library for interacting with JSON on Android. The open-ended reflection in the Gson runtime doesn't play nicely with shrinking/optimization/obfuscation passes that Android release apps should perform.\\\n\u003e If your app or library may be running on Android, consider using [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#basics) or [Moshi's Codegen](https://github.com/square/moshi?tab=readme-ov-file#codegen),\n\u003e which use code generation instead of reflection. This avoids Gson's runtime crashes when optimizations are applied (usually due to the fields missing or being obfuscated), and results in faster performance on Android devices.\n\u003e The Moshi APIs may be more familiar to users who already know Gson.\n\u003e If you still want to use Gson and attempt to avoid these crashes, you can see how to do so [here](Troubleshooting.md#proguard-r8).\n\n### Goals\n  * Provide simple `toJson()` and `fromJson()` methods to convert Java objects to JSON and vice-versa\n  * Allow pre-existing unmodifiable objects to be converted to and from JSON\n  * Extensive support of Java Generics\n  * Allow custom representations for objects\n  * Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types)\n\n### Download\n\nGradle:\n```gradle\ndependencies {\n  implementation 'com.google.code.gson:gson:2.13.2'\n}\n```\n\nMaven:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.google.code.gson\u003c/groupId\u003e\n  \u003cartifactId\u003egson\u003c/artifactId\u003e\n  \u003cversion\u003e2.13.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n[Gson jar downloads](https://maven-badges.herokuapp.com/maven-central/com.google.code.gson/gson) are available from Maven Central.\n\n![Build Status](https://github.com/google/gson/actions/workflows/build.yml/badge.svg)\n\n### Requirements\n#### Minimum Java version\n- Gson 2.12.0 and newer: Java 8\n- Gson 2.9.0 to 2.11.0: Java 7\n- Gson 2.8.9 and older: Java 6\n\nDespite supporting older Java versions, Gson also provides a JPMS module descriptor (module name `com.google.gson`) for users of Java 9 or newer.\n\n#### JPMS dependencies (Java 9+)\nThese are the optional Java Platform Module System (JPMS) JDK modules which Gson depends on.\nThis only applies when running Java 9 or newer.\n\n- `java.sql` (optional since Gson 2.8.9)\\\nWhen this module is present, Gson provides default adapters for some SQL date and time classes.\n\n- `jdk.unsupported`, respectively class `sun.misc.Unsafe` (optional)\\\nWhen this module is present, Gson can use the `Unsafe` class to create instances of classes without no-args constructor.\nHowever, care should be taken when relying on this. `Unsafe` is not available in all environments and its usage has some pitfalls,\nsee [`GsonBuilder.disableJdkUnsafe()`](https://javadoc.io/doc/com.google.code.gson/gson/latest/com.google.gson/com/google/gson/GsonBuilder.html#disableJdkUnsafe()).\n\n#### Minimum Android API level\n\n- Gson 2.11.0 and newer: API level 21\n- Gson 2.10.1 and older: API level 19\n\nOlder Gson versions may also support lower API levels, however this has not been verified.\n\n### Documentation\n  * [API Javadoc](https://www.javadoc.io/doc/com.google.code.gson/gson): Documentation for the current release\n  * [User guide](UserGuide.md): This guide contains examples on how to use Gson in your code\n  * [Troubleshooting guide](Troubleshooting.md): Describes how to solve common issues when using Gson\n  * [Releases and change log](https://github.com/google/gson/releases): Latest releases and changes in these versions; for older releases see [`CHANGELOG.md`](CHANGELOG.md)\n  * [Design document](GsonDesignDocument.md): This document discusses issues we faced while designing Gson. It also includes a comparison of Gson with other Java libraries that can be used for Json conversion\n\nPlease use the ['gson' tag on StackOverflow](https://stackoverflow.com/questions/tagged/gson), [GitHub Discussions](https://github.com/google/gson/discussions) or the [google-gson Google group](https://groups.google.com/group/google-gson) to discuss Gson or to post questions.\n\n### ProGuard / R8\n\nSee the details in the related section in the [Troubleshooting guide](Troubleshooting.md#proguard-r8).\n\n### Related Content Created by Third Parties\n  * [Gson Tutorial](https://www.studytrails.com/java/json/java-google-json-introduction/) by `StudyTrails`\n  * [Gson Tutorial Series](https://futurestud.io/tutorials/gson-getting-started-with-java-json-serialization-deserialization) by `Future Studio`\n  * [Gson API Report](https://abi-laboratory.pro/java/tracker/timeline/gson/)\n\n### Building\n\nGson uses Maven to build the project:\n```\nmvn clean verify\n```\n\nJDK 17 or newer is required for building, JDK 21 is recommended. Newer JDKs are currently not supported for building (but are supported when _using_ Gson).\n\n### Contributing\n\nSee the [contributing guide](https://github.com/google/.github/blob/master/CONTRIBUTING.md).\\\nPlease perform a quick search to check if there are already existing issues or pull requests related to your contribution.\n\nKeep in mind that Gson is in maintenance mode. If you want to add a new feature, please first search for existing GitHub issues, or create a new one to discuss the feature and get feedback.\n\n### License\n\nGson is released under the [Apache 2.0 license](LICENSE).\n\n```\nCopyright 2008 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n### Disclaimer\n\nThis is not an officially supported Google product.\n","funding_links":[],"categories":["III. Network and Integration","Java","Libraries","JSON","Projects","常用框架\\\u0026第三方库","库","Index","dependency list",":shamrock:  **Categories**","Android 开发中的日常积累","项目","JSON Parsing","二、核心功能库（解决具体开发问题）","1. Important library","Cross-Platform Mobile Guide for Native iOS \u0026 Android Developers","Solutions"],"sub_categories":["8.  Json","JSON","实用工具",":books: Libraries","安卓Json解析","2. JSON处理","Android","[](https://github.com/JStumpp/awesome-android/blob/master/readme.md#json)JSON"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fgson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgson/lists"}