{"id":19944719,"url":"https://github.com/rameshmf/gson-tutorial","last_synced_at":"2026-03-12T06:01:54.935Z","repository":{"id":99531906,"uuid":"154926550","full_name":"RameshMF/gson-tutorial","owner":"RameshMF","description":"Guide to google gson library ","archived":false,"fork":false,"pushed_at":"2018-12-29T17:22:26.000Z","size":34,"stargazers_count":7,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-03T16:34:03.948Z","etag":null,"topics":["custom-serialization","deserialize","gson","gson-library","java-objects","json-representation","json-string"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RameshMF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-10-27T04:40:50.000Z","updated_at":"2022-08-18T11:36:43.000Z","dependencies_parsed_at":"2023-07-30T19:16:01.694Z","dependency_job_id":null,"html_url":"https://github.com/RameshMF/gson-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RameshMF/gson-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RameshMF%2Fgson-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RameshMF%2Fgson-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RameshMF%2Fgson-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RameshMF%2Fgson-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RameshMF","download_url":"https://codeload.github.com/RameshMF/gson-tutorial/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RameshMF%2Fgson-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30416734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T04:41:02.746Z","status":"ssl_error","status_checked_at":"2026-03-12T04:40:12.571Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["custom-serialization","deserialize","gson","gson-library","java-objects","json-representation","json-string"],"created_at":"2024-11-13T00:22:33.560Z","updated_at":"2026-03-12T06:01:54.929Z","avatar_url":"https://github.com/RameshMF.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gson-tutorial\nGuide to google gson library \n\n\u003cdiv class=\"font-family-page\"\u003e\n\u003cdiv style=\"box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\n\u003ca href=\"https://github.com/google/gson\" target=\"_blank\"\u003eGson\u003c/a\u003e 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.\u003c/div\u003e\n\u003cdiv style=\"box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\nGson can work with arbitrary Java objects including pre-existing objects that you do not have a source code of.\u0026nbsp;The following tutorials will demonstrate how you can leverage GSON to manage your JSON conversions.\u003c/div\u003e\n\u003cdiv style=\"box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\n\u003cspan style=\"background-color: white;\"\u003eGson was originally created for use inside Google where it is currently used in a number of projects. It is now used by a number of public projects and companies.\u003c/span\u003e\u003c/div\u003e\n\u003ch2 style=\"border-bottom: 1px solid rgb(234, 236, 239); box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;\"\u003e\nGoals for Gson\u003c/h2\u003e\n\u003cul style=\"box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;\"\u003e\n\u003cli style=\"box-sizing: border-box;\"\u003eProvide easy to use mechanisms like\u0026nbsp;\u003ccode style=\"background-color: rgba(27, 31, 35, 0.05); border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, \u0026quot;Liberation Mono\u0026quot;, Menlo, Courier, monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em;\"\u003etoString()\u003c/code\u003e\u0026nbsp;and constructor (factory method) to convert Java to JSON and vice-versa\u003c/li\u003e\n\u003cli style=\"box-sizing: border-box; margin-top: 0.25em;\"\u003eAllow pre-existing unmodifiable objects to be converted to and from JSON\u003c/li\u003e\n\u003cli style=\"box-sizing: border-box; margin-top: 0.25em;\"\u003eAllow custom representations for objects\u003c/li\u003e\n\u003cli style=\"box-sizing: border-box; margin-top: 0.25em;\"\u003eSupport arbitrarily complex objects\u003c/li\u003e\n\u003cli style=\"box-sizing: border-box; margin-top: 0.25em;\"\u003eGenerate compact and readable JSON output\u003c/li\u003e\n\u003c/ul\u003e\n\u003cdiv\u003e\n\u003ch2 style=\"background-color: white; border-bottom: 1px solid rgb(234, 236, 239); box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;\"\u003e\nGSON Maven Dependency\u003c/h2\u003e\n\u003cdiv style=\"background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\nTo use Gson with Maven2/3, you can use the Gson version available in Maven Central by adding the following dependency:\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-text-xml\" style=\"background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\n\u003cpre style=\"background-color: #f6f8fa; border-radius: 3px; border: 1px solid rgb(61, 133, 198); box-sizing: border-box; font-family: SFMono-Regular, Consolas, \u0026quot;Liberation Mono\u0026quot;, Menlo, Courier, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;\"\u003e\u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003edependencies\u003c/span\u003e\u0026gt;\n    \u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003edependency\u003c/span\u003e\u0026gt;\n      \u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003egroupId\u003c/span\u003e\u0026gt;com.google.code.gson\u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003egroupId\u003c/span\u003e\u0026gt;\n      \u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003eartifactId\u003c/span\u003e\u0026gt;gson\u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003eartifactId\u003c/span\u003e\u0026gt;\n      \u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003eversion\u003c/span\u003e\u0026gt;2.8.5\u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003eversion\u003c/span\u003e\u0026gt;\n      \u0026lt;\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003escope\u003c/span\u003e\u0026gt;compile\u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003escope\u003c/span\u003e\u0026gt;\n    \u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003edependency\u003c/span\u003e\u0026gt;\n\u0026lt;/\u003cspan class=\"pl-ent\" style=\"box-sizing: border-box; color: #22863a;\"\u003edependencies\u003c/span\u003e\u0026gt;\u003c/pre\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2 style=\"background-color: white; border-bottom: 1px solid rgb(234, 236, 239); box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; line-height: 1.25; margin-bottom: 16px; margin-top: 0px !important; padding-bottom: 0.3em;\"\u003e\nTwo ways to create Gson objects\u003c/h2\u003e\n\u003cdiv style=\"background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px;\"\u003e\nGson object can be created in two ways. First way gives you a quick \u003ci\u003eGson\u003c/i\u003e object ready for faster coding, while the second way uses \u003ci\u003eGsonBuilder\u003c/i\u003e to build a more sophisticated \u003ci\u003eGson\u003c/i\u003e object.\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-java\" style=\"background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px; overflow: visible !important;\"\u003e\n\u003cpre style=\"background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, \u0026quot;Liberation Mono\u0026quot;, Menlo, Courier, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;\"\u003e\u003cspan class=\"pl-c\" style=\"box-sizing: border-box; color: #6a737d;\"\u003e\u003cspan class=\"pl-c\" style=\"box-sizing: border-box;\"\u003e//\u003c/span\u003eFirst way to create a Gson object for faster coding\u003c/span\u003e\n\u003cspan class=\"pl-smi\" style=\"box-sizing: border-box;\"\u003eGson\u003c/span\u003e gson \u003cspan class=\"pl-k\" style=\"box-sizing: border-box; color: #d73a49;\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-k\" style=\"box-sizing: border-box; color: #d73a49;\"\u003enew\u003c/span\u003e \u003cspan class=\"pl-smi\" style=\"box-sizing: border-box;\"\u003eGson\u003c/span\u003e();\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-java\" style=\"background-color: white; box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; font-size: 16px; margin-bottom: 16px; overflow: visible !important;\"\u003e\n\u003cpre style=\"background-color: #f6f8fa; border-radius: 3px; box-sizing: border-box; font-family: SFMono-Regular, Consolas, \u0026quot;Liberation Mono\u0026quot;, Menlo, Courier, monospace; font-size: 13.6px; line-height: 1.45; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;\"\u003e\u003cspan class=\"pl-c\" style=\"box-sizing: border-box; color: #6a737d;\"\u003e\u003cspan class=\"pl-c\" style=\"box-sizing: border-box;\"\u003e//\u003c/span\u003eSecond way to create a Gson object using GsonBuilder\u003c/span\u003e\n\u003cspan class=\"pl-smi\" style=\"box-sizing: border-box;\"\u003eGson\u003c/span\u003e gson \u003cspan class=\"pl-k\" style=\"box-sizing: border-box; color: #d73a49;\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-k\" style=\"box-sizing: border-box; color: #d73a49;\"\u003enew\u003c/span\u003e \u003cspan class=\"pl-smi\" style=\"box-sizing: border-box;\"\u003eGsonBuilder\u003c/span\u003e()\n             .disableHtmlEscaping()\n             .setFieldNamingPolicy(\u003cspan class=\"pl-smi\" style=\"box-sizing: border-box;\"\u003eFieldNamingPolicy\u003c/span\u003e\u003cspan class=\"pl-c1\" style=\"box-sizing: border-box; color: #005cc5;\"\u003e\u003cspan class=\"pl-k\" style=\"box-sizing: border-box; color: #d73a49;\"\u003e.\u003c/span\u003eUPPER_CAMEL_CASE\u003c/span\u003e)\n             .setPrettyPrinting()\n             .serializeNulls()\n             .create();\u003c/pre\u003e\n\u003c/div\u003e\n\u003ch2 style=\"background-color: white; border-bottom: 1px solid rgb(234, 236, 239); box-sizing: border-box; color: #24292e; font-family: -apple-system, BlinkMacSystemFont, \u0026quot;Segoe UI\u0026quot;, Helvetica, Arial, sans-serif, \u0026quot;Apple Color Emoji\u0026quot;, \u0026quot;Segoe UI Emoji\u0026quot;, \u0026quot;Segoe UI Symbol\u0026quot;; line-height: 1.25; margin-bottom: 16px; margin-top: 0px !important; padding-bottom: 0.3em;\"\u003e\nUsing Gson and GsonBuilder Examples\u003c/h2\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-serialize-and-deserialize-primitive-types.html\" target=\"_blank\"\u003eGSON - Serialize and Deserialize Primitives Types\u003c/a\u003e\u003c/li\u003e\nIn this quick article, we will discuss how to use GSON to serialize or deserialize any primitive type into JSON representation.\u003c/ul\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/convert-java-object-to-json-using-gson.html\" target=\"_blank\"\u003eConvert Java Object to JSON using GSON\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eIn this article, we will create an example to converting or serializing Java object to JSON representation using the\u0026nbsp;\u003c/span\u003eGSON library\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e.\u003c/span\u003e\u003c/ul\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/convert-json-to-java-object-using-gson.html\" target=\"_blank\"\u003eConvert JSON to Java Object using GSON\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eIn this article, we will create an example to convert JSON representation to Java Object using the\u0026nbsp;\u003c/span\u003eGSON library\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e.\u003c/span\u003e\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-serialize-and-deserialize-collections-example.html\" style=\"font-size: 16px;\" target=\"_blank\"\u003eGSON - Serialize and Deserialize Collections Example\u003c/a\u003e\u003c/li\u003e\nIn this example, we serialize a collection of Integer and Employee objects into JSON representation and using the TypeToken to deserialize the collection of Integers into the arbitrary Java Object.\u003c/ul\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-serializing-and-deserializing-generic-types.html\" target=\"_blank\"\u003eGSON - Serializing and Deserializing Generic Types\u003c/a\u003e\u003c/li\u003e\nIn this quick article, we will see how to serialize and deserialize a generic class using GSON. Generic type information is lost while serializing because of Java Type Erasure. You can solve this problem by specifying the correct parameterized type for your generic type. Gson provides this with the \u003ci\u003eTypeToken\u003c/i\u003e class.\u003cbr\u003e\n\u003cbr\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-serializing-and-deserializing-enums.html\" target=\"_blank\"\u003eGSON - Serializing and Deserializing Enums\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eIn this quick article, we show you how to serialize and deserialize\u0026nbsp;\u003c/span\u003eenum types\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;to and from its JSON representation.\u003c/span\u003e\u003cbr\u003e\n\u003cbr\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-serializing-inner-classes-example.html\" target=\"_blank\"\u003eGson - Serializing Inner Classes Example\u003c/a\u003e\u003c/li\u003e\nIn this article, we will discuss how to serialization/deserialization of classes having inner classes.\u003c/ul\u003e\n\u003cdiv\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-array-and-multi-dimensional-array-example.html\" target=\"_blank\"\u003eGSON - Array and Multi-Dimensional Array Example\u003c/a\u003e\u003c/li\u003e\nIn this quick article, we show you how to serialize and deserialize an array or a multidimensional array to and from its JSON representation.\u003c/ul\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-custom-serialization-and-deseriliazation-examples.html\" style=\"font-size: 16px;\" target=\"_blank\"\u003eGSON - Custom Serialization and Deserialization Examples\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eMany times, we need to write/read the JSON values which do not default representation of java object. In that case, Gson allows you to register your own custom serializer and deserializer.\u003c/span\u003e\u003c/ul\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-excluding-fields-from-json-with-expose-annotation.html\" target=\"_blank\"\u003eGSON - Excluding fields from JSON with @Expose Annotation\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eIn this quick article, we will discuss how to mark certain fields of our Java objects to be excluded for consideration for serialization and deserialization to JSON.\u003c/span\u003e\u003cbr\u003e\u003cbr\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-null-object-support.html\" target=\"_blank\"\u003eGSON - Null Object Support\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: rgba(27 , 31 , 35 , 0.05); color: #d73a49; font-family: \u0026quot;consolas\u0026quot; , \u0026quot;liberation mono\u0026quot; , \u0026quot;courier\u0026quot; , monospace; font-size: 14.4px; padding: 0.2em 0.4em;\"\u003eGson\u003c/span\u003e\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;by default generates optimized JSON content ignoring the NULL values. But\u0026nbsp;\u003c/span\u003e\u003cspan style=\"background-color: rgba(27 , 31 , 35 , 0.05); color: #d73a49; font-family: \u0026quot;consolas\u0026quot; , \u0026quot;liberation mono\u0026quot; , \u0026quot;courier\u0026quot; , monospace; font-size: 14.4px; padding: 0.2em 0.4em;\"\u003eGsonBuilder\u003c/span\u003e\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;provides flags to show NULL values in the JSON output using the\u0026nbsp;\u003c/span\u003e\u003cspan style=\"background-color: rgba(27 , 31 , 35 , 0.05); color: #d73a49; font-family: \u0026quot;consolas\u0026quot; , \u0026quot;liberation mono\u0026quot; , \u0026quot;courier\u0026quot; , monospace; font-size: 14.4px; padding: 0.2em 0.4em;\"\u003eGsonBuilder.serializeNulls()\u003c/span\u003e\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;method.\u003c/span\u003e\u003cbr\u003e\u003cbr\u003e\n\u003cli\u003e\u003ca href=\"http://www.javaguides.net/2018/10/gson-version-support-example.html\" target=\"_blank\"\u003eGSON - Version Support Example\u003c/a\u003e\u003c/li\u003e\n\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003eIn this quick article, we will discuss how to use\u0026nbsp;\u003c/span\u003e\u003cspan style=\"background-color: rgba(27 , 31 , 35 , 0.05); color: #d73a49; font-family: \u0026quot;consolas\u0026quot; , \u0026quot;liberation mono\u0026quot; , \u0026quot;courier\u0026quot; , monospace; font-size: 14.4px; padding: 0.2em 0.4em;\"\u003e@Since\u003c/span\u003e\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;annotation to support multiple versions of the same object. GSON introduced the\u0026nbsp;\u003c/span\u003e\u003cspan style=\"background-color: rgba(27 , 31 , 35 , 0.05); color: #d73a49; font-family: \u0026quot;consolas\u0026quot; , \u0026quot;liberation mono\u0026quot; , \u0026quot;courier\u0026quot; , monospace; font-size: 14.4px; padding: 0.2em 0.4em;\"\u003e@Since\u003c/span\u003e\u003cspan style=\"background-color: white; color: #24292e; font-family: , \u0026quot;blinkmacsystemfont\u0026quot; , \u0026quot;segoe ui\u0026quot; , \u0026quot;helvetica\u0026quot; , \u0026quot;arial\u0026quot; , sans-serif , \u0026quot;apple color emoji\u0026quot; , \u0026quot;segoe ui emoji\u0026quot; , \u0026quot;segoe ui symbol\u0026quot;; font-size: 16px;\"\u003e\u0026nbsp;annotation to support multiple versions of the same object. We can use this annotation on Classes and Fields.\u003c/span\u003e\u003c/ul\u003e\n\u003cul style=\"text-align: left;\"\u003e\n\u003cli\u003e\u003ca href=\"https://www.baeldung.com/gson-json-to-map\" target=\"_blank\"\u003eConvert JSON to a Map Using Gson\u003c/a\u003e\u003c/li\u003e\nIn this quick tutorial, we’ll learn how to convert a JSON string to a Map using Gson from Google.\n\nWe’ll see three different approaches to accomplish that and discuss their pros and cons – with some practical examples.\u003c/ul\u003e\n\u003ch2 style=\"background-color: white; border-bottom: 1px solid rgb(234, 236, 239); box-sizing: border-box; color: #24292e; line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;\"\u003e\nReference\u003c/h2\u003e\n\u003cdiv\u003e\n\u003ca href=\"https://github.com/google/gson/blob/master/UserGuide.md\" target=\"_blank\"\u003eGSON User Guide\u003c/a\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ca href=\"https://google.github.io/gson/apidocs/\" target=\"_blank\"\u003eGSON Java DOC\u003c/a\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameshmf%2Fgson-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frameshmf%2Fgson-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frameshmf%2Fgson-tutorial/lists"}