{"id":17343833,"url":"https://github.com/augi/gson-scala","last_synced_at":"2025-10-09T15:13:04.886Z","repository":{"id":71633098,"uuid":"56385713","full_name":"augi/gson-scala","owner":"augi","description":"Allows to use Scala and Java 8 types with gson library.","archived":false,"fork":false,"pushed_at":"2017-01-11T11:29:18.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T18:53:36.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/augi.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2016-04-16T13:43:52.000Z","updated_at":"2020-06-29T06:37:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"57c228fc-378c-4984-ba19-783ca3a4d1cb","html_url":"https://github.com/augi/gson-scala","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/augi/gson-scala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augi%2Fgson-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augi%2Fgson-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augi%2Fgson-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augi%2Fgson-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/augi","download_url":"https://codeload.github.com/augi/gson-scala/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/augi%2Fgson-scala/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001643,"owners_count":26083146,"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-10-15T16:10:27.625Z","updated_at":"2025-10-09T15:13:04.869Z","avatar_url":"https://github.com/augi.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This project is no longer maintained!\n[gson](https://github.com/google/gson) library heavily depends on reflection and so it's hard to keep the support for Scala. Use [json4s](http://json4s.org/) or [circe](https://github.com/circe/circe) library instead.\n\n# gson-scala\n\n[![Build Status](https://travis-ci.org/augi/gson-scala.svg?branch=master)](https://travis-ci.org/augi/gson-scala) [![Download](https://api.bintray.com/packages/augi/maven/gson-scala_2.12/images/download.svg) ](https://bintray.com/augi/maven/gson-scala_2.12/_latestVersion)\n\nAllows to use Scala and Java 8 types with [gson library](https://github.com/google/gson).\n\nSupported types:\n* `java.time.Instant`\n* `java.time.Duration`\n* `scala.concurrent.duration.Duration`\n* `java.util.Optional`\n* `scala.Option`\n* `scala.Seq`\n\n## How to use\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecz.augi.gsonscala\u003c/groupId\u003e\n    \u003cartifactId\u003egson-scala_2.12\u003c/artifactId\u003e\n    \u003cversion\u003e$latestVersion\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```gradle\ncompile \"cz.augi.gsonscala:gson-scala_2.12:$latestVersion\"\n```\n\n```scala\nimport cz.augi.gsonscala._\nval gson = new GsonBuilder()\n                .registerMillisDurationConverters() // registers for Duration classes expecting millis in integer values\n                .registerUnixMillisInstantConverter() // registers for Instant expecting Unix millis in integer values\n                .registerBasicConverters() // registers for Optional, Option and Seq\n                .create()\n```\n\nThe `registerBasicConverters``must be called as the last method before the `create` method.\n\nAlternatively, these methods can be used for registrations:\n* `registerSecondsDurationConverters` - expects durations in seconds\n* `registerStringDurationConverters`\n* `registerUnixSecondsInstantConverter` - expects time in Unix timestamp (seconds)\n* `registerStringInstantConverter` - expects time in ISO format\n\nYou can also cherry-pick some of converters [as shown here](https://github.com/augi/gson-scala/blob/master/src/main/scala/cz/augi/gsonscala/package.scala).\n\n\u003e Please note that `registerBasicConverters` also registers [NonNullTypeAdapterFactory](https://github.com/augi/gson-scala/blob/master/src/main/scala/cz/augi/gsonscala/NonNullTypeAdapterFactory.scala) - it's required\n because the default object deserializer doesn't call deserializer of a field if the value is not even present in the json.\n\n## Why to use this library?\nAs gson library targets Java 6, it doesn't support Java 8 type out of the box. There are several libraries that add support\nfor `Optional` type but most of them is not able to handle missing value correctly.\n \nFor example [gson-java8-datatype](https://github.com/caoqianli/gson-java8-datatype) looked promising but\nit has [too simple tests](https://github.com/caoqianli/gson-java8-datatype/blob/master/src/test/java/net/dongliu/gson/GsonJava8TypeAdapterFactoryTest.java).\nE.g. if you have a class with `Optional` field then the deserialized object contains `null` instead of `Optional.empty()`.\n\nThe problem is that `gson` by default doesn't write `null` values. So the `read` method of `TypeAdapter` is not even called for missing value\nand the field of deserialized object has `null` value. Tests of `gson-java8-datatype` are passing because `null` value is written if it's top-level object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugi%2Fgson-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faugi%2Fgson-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faugi%2Fgson-scala/lists"}