{"id":21754021,"url":"https://github.com/vuzi/play-json-auto-sealed-trait","last_synced_at":"2025-09-13T05:35:15.597Z","repository":{"id":74252594,"uuid":"118923342","full_name":"Vuzi/play-json-auto-sealed-trait","owner":"Vuzi","description":"Auto generation of writer/reader/format for sealed trait, using play-json","archived":false,"fork":false,"pushed_at":"2018-02-20T16:30:00.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-25T23:38:50.751Z","etag":null,"topics":["json-format","play-json","scala","scala-macros"],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/Vuzi.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":"2018-01-25T14:29:23.000Z","updated_at":"2018-01-30T08:58:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"1fe446db-ddfe-4621-9b9a-16b042eb0e38","html_url":"https://github.com/Vuzi/play-json-auto-sealed-trait","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vuzi%2Fplay-json-auto-sealed-trait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vuzi%2Fplay-json-auto-sealed-trait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vuzi%2Fplay-json-auto-sealed-trait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vuzi%2Fplay-json-auto-sealed-trait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vuzi","download_url":"https://codeload.github.com/Vuzi/play-json-auto-sealed-trait/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244728234,"owners_count":20500023,"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":["json-format","play-json","scala","scala-macros"],"created_at":"2024-11-26T09:12:39.262Z","updated_at":"2025-03-21T03:13:24.627Z","avatar_url":"https://github.com/Vuzi.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Auto format for sealed trait using `play-json`\n## Features\n- Automatic generation of reader/writer for sealed trait\n- Handle case class, case object, objects, nested case class/object and sub type extending the sealed trait\n- Customisable JSON type field\n\n## Description\nAuto generation of writer/reader/format for sealed trait, using `play-json`. The key difference with `play-json` sealed trait macro is that here the readers/writers of every class or object implementing the sealed trait is automatically generated using the `play-json` existing macros. This allow for quick `format` generation where the default format would have been used.\n\n## Example/Usage\n```scala\nsealed trait Test\n\ncase class TestA(value: Int) extends Test\n\ncase class TestB(value: String) extends Test\n\nobject TestC extends Test\n\nsealed trait Test2 extends Test\n\ncase class Test2A(a: Int) extends Test2\n\nsealed trait Test3 extends Test2\n\ncase class Test3A(a: String) extends Test3\n\nobject Test {\n  case class TestD(value: String) extends Test\n\n  object TestE extends Test\n\n  case object TestF extends Test\n\n  object InnerTest {\n    case object TestInner extends Test\n  }\n\n  implicit val writer: Format[Test] = format[Test]\n}\n\nobject MacroTest extends App {\n\n  val testA = TestA(42)\n  val testB = TestB(\"hello\")\n  val testC = TestC\n  val testD = TestD(\"hey\")\n  val testE = TestE\n  val testF = TestF\n  val testI = TestInner\n  val test2A = Test2A(42)\n  val test3A = Test3A(\"42\")\n\n  assert(Json.fromJson[Test](Json.toJson(testA)) == JsSuccess(testA))\n  assert(Json.fromJson[Test](Json.toJson(testB)) == JsSuccess(testB))\n  assert(Json.fromJson[Test](Json.toJson(testC)) == JsSuccess(testC))\n  assert(Json.fromJson[Test](Json.toJson(testD)) == JsSuccess(testD))\n  assert(Json.fromJson[Test](Json.toJson(testE)) == JsSuccess(testE))\n  assert(Json.fromJson[Test](Json.toJson(testF)) == JsSuccess(testF))\n  assert(Json.fromJson[Test](Json.toJson(testI)) == JsSuccess(testI))\n  assert(Json.fromJson[Test](Json.toJson(test2A)) == JsSuccess(test2A))\n  assert(Json.fromJson[Test](Json.toJson(test3A)) == JsSuccess(test3A))\n\n}\n\n```\n\nHeavily inspired by [`play-json`](https://github.com/playframework/play-json) own macros!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuzi%2Fplay-json-auto-sealed-trait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvuzi%2Fplay-json-auto-sealed-trait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvuzi%2Fplay-json-auto-sealed-trait/lists"}