{"id":21006262,"url":"https://github.com/derlin/gsonutils","last_synced_at":"2025-10-09T14:29:08.432Z","repository":{"id":151664222,"uuid":"38127291","full_name":"derlin/GsonUtils","owner":"derlin","description":"A java .jar easing the use of the Gson library.","archived":false,"fork":false,"pushed_at":"2015-12-01T15:37:30.000Z","size":525,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T14:43:39.582Z","etag":null,"topics":[],"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/derlin.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}},"created_at":"2015-06-26T18:33:43.000Z","updated_at":"2024-06-22T02:46:17.000Z","dependencies_parsed_at":"2023-04-14T19:04:57.893Z","dependency_job_id":null,"html_url":"https://github.com/derlin/GsonUtils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derlin/GsonUtils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2FGsonUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2FGsonUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2FGsonUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2FGsonUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derlin","download_url":"https://codeload.github.com/derlin/GsonUtils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2FGsonUtils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001537,"owners_count":26083119,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-19T08:50:27.131Z","updated_at":"2025-10-09T14:29:08.404Z","avatar_url":"https://github.com/derlin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GsonUtils\nA java .jar easing the use of the Gson library. The class `GsonUtils` offers static methods to quickly:\n* load an object from a json file\n* serialize an object into a string\n* serialize an object into a file\n* exclude fields from the serialization with the `@DoNotSerialize` annotation.\n\n# How to use\n\nAdd the jar to the classpath.\n\nTo serialize __an object into a file__, you two methods, taking either a path to a file or the file itself. For example, \nif you have an object, you can do:\n\n```java\nMyObject myObject = new MyObject();\nGsonUtils.writeToFile(\"/path/to/a/file.json\", myObject, true);\n```\n\nThe boolean parameter determines if the output should be prettyprinted or not.\n\nIf your object is a collection or another generic object, you can use the `TypeToken` class, like that:\n\n```java\nMap\u003cString,MyObject\u003e map = new HashMap\u003c\u003e();\nGsonUtils.writeToFile(\"/path/to/a/file.json\", new TypeToken\u003cHashMap\u003cString,MyObject\u003e\u003e(){}, true);\n```\n\nTo deserialize a __json file to an object__, the principle is the same:\n\n```java\nMyObject myObject =v (MyObject) GsonUtils.getFromFile(\"/path/to/a/file.json\", new MyObject());\nMap\u003cString,MyObject\u003e map = (HashMap\u003cString,MyObject\u003e)\n    GsonUtils.getFromFile(\"/path/to/a/file.json\", new TypeToken\u003cHashMap\u003cString,MyObject\u003e\u003e(){});\n```\n\nFinally, you can serialize __an object into a string__. The method `dump` serialize every field, the method `toJson` will \nexclude any field annotated with `@DoNotSerialize`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fgsonutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderlin%2Fgsonutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fgsonutils/lists"}