{"id":37428305,"url":"https://github.com/paoloboni/spray-json-derived-codecs","last_synced_at":"2026-01-16T06:32:43.522Z","repository":{"id":38015922,"uuid":"324408886","full_name":"paoloboni/spray-json-derived-codecs","owner":"paoloboni","description":"Derived codecs for spray-json for Scala 3.x and 2.x","archived":false,"fork":false,"pushed_at":"2024-05-05T00:30:05.000Z","size":205,"stargazers_count":5,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-05T01:28:00.339Z","etag":null,"topics":["auto-derivation","derived-codecs","polymorphic-types","recursive-types","spray-json"],"latest_commit_sha":null,"homepage":"","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/paoloboni.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":"2020-12-25T17:56:38.000Z","updated_at":"2024-05-05T01:28:03.101Z","dependencies_parsed_at":"2023-02-18T20:20:37.069Z","dependency_job_id":"62a898f8-553a-4aee-9844-727a68411a8b","html_url":"https://github.com/paoloboni/spray-json-derived-codecs","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/paoloboni/spray-json-derived-codecs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paoloboni%2Fspray-json-derived-codecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paoloboni%2Fspray-json-derived-codecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paoloboni%2Fspray-json-derived-codecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paoloboni%2Fspray-json-derived-codecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paoloboni","download_url":"https://codeload.github.com/paoloboni/spray-json-derived-codecs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paoloboni%2Fspray-json-derived-codecs/sbom","scorecard":{"id":719704,"data":{"date":"2025-08-11","repo":{"name":"github.com/paoloboni/spray-json-derived-codecs","commit":"56ec2fb96b86cbc86a805c6c69ef8a980c033670"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.4,"checks":[{"name":"Code-Review","score":9,"reason":"Found 27/30 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/release-drafter.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/scala-steward.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release-drafter.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/release-drafter.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/scala-steward.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/paoloboni/spray-json-derived-codecs/scala-steward.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   7 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":10,"reason":"SAST tool detected","details":["Info: SAST configuration detected: Snyk","Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T10:55:00.909Z","repository_id":38015922,"created_at":"2025-08-22T10:55:00.909Z","updated_at":"2025-08-22T10:55:00.909Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: 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":["auto-derivation","derived-codecs","polymorphic-types","recursive-types","spray-json"],"created_at":"2026-01-16T06:32:43.422Z","updated_at":"2026-01-16T06:32:43.501Z","avatar_url":"https://github.com/paoloboni.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spray-json derived codecs\n\n[![Build Status](https://github.com/paoloboni/spray-json-derived-codecs/actions/workflows/ci.yml/badge.svg)](https://github.com/paoloboni/spray-json-derived-codecs/actions?query=workflow)\n[![Latest version](https://img.shields.io/maven-central/v/io.github.paoloboni/spray-json-derived-codecs_2.13.svg)](https://search.maven.org/artifact/io.github.paoloboni/spray-json-derived-codecs_2.13)\n[![codecov.io](http://codecov.io/github/paoloboni/spray-json-derived-codecs/coverage.svg?branch=master)](http://codecov.io/github/paoloboni/spray-json-derived-codecs?branch=master)\n[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n`JsonFormat` derivation for algebraic data types, inspired by [Play Json Derived Codecs](https://github.com/julienrf/play-json-derived-codecs).\n\nThe derivation built with Scala 2.x is powered by [shapeless](https://github.com/milessabin/shapeless), whereas the one built with Scala 3 is based on the new [Type Class Derivation](https://dotty.epfl.ch/docs/reference/contextual/derivation.html) language API. \n\nThe derivation currently supports:\n- sum types\n- product types\n- recursive types\n- polymorphic types\n\nThis library is built with Sbt 1.5.2 or later, and its master branch is built with Scala 2.13.6 by default but also cross-builds for 3 and 2.12.\n\n---\n**NOTE**\n\nScala 2.11 is no longer supported. The latest version available for scala 2.11 is 2.2.2.\n\n---\n\n## Installation\n\nIf you use sbt add the following dependency to your build file:\n\n```sbtshell\nlibraryDependencies += \"io.github.paoloboni\" %% \"spray-json-derived-codecs\" % \"\u003cversion\u003e\"\n```\n\n## Usage\n\nFor automatic derivation, add the following import:\n\n```scala\nimport spray.json.derived.auto._\n```\n\nIf you prefer to explicitly define your formats, then you can use semi-auto derivation:\n\n```scala\nimport spray.json.derived.semiauto._\n```\n\n### Examples\n\n#### Product types\n\n##### Auto derivation\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\ncase class Cat(name: String, livesLeft: Int)\n\nobject Test extends App {\n  val oliver: Cat = Cat(\"Oliver\", 7)\n  val encoded     = oliver.toJson\n  \n  assert(encoded == \"\"\"{\"livesLeft\":7,\"name\":\"Oliver\"}\"\"\".parseJson)\n  assert(encoded.convertTo[Cat] == oliver)\n}\n```\n\n##### Semi-auto derivation\n\n```scala\nimport spray.json._\nimport spray.json.derived.semiauto._\nimport spray.json.DefaultJsonProtocol._\n\ncase class Cat(name: String, livesLeft: Int)\n\nobject Test extends App {\n  implicit val format: JsonFormat[Cat] = deriveFormat[Cat]\n\n  val oliver: Cat = Cat(\"Oliver\", 7)\n  val encoded     = oliver.toJson\n\n  assert(encoded == \"\"\"{\"livesLeft\":7,\"name\":\"Oliver\"}\"\"\".parseJson)\n  assert(encoded.convertTo[Cat] == oliver)\n}\n```\n\n#### Union types\n\nUnion types are encoded by using a discriminator field, which by default is `type`.\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\nsealed trait Pet\ncase class Cat(name: String, livesLeft: Int)   extends Pet\ncase class Dog(name: String, bonesHidden: Int) extends Pet\n\nobject Test extends App {\n  val oliver: Pet   = Cat(\"Oliver\", 7)\n  val encodedOliver = oliver.toJson\n  assert(encodedOliver == \"\"\"{\"livesLeft\":7,\"name\":\"Oliver\",\"type\":\"Cat\"}\"\"\".parseJson)\n  assert(encodedOliver.convertTo[Pet] == oliver)\n\n  val albert: Pet   = Dog(\"Albert\", 3)\n  val encodedAlbert = albert.toJson\n  assert(encodedAlbert == \"\"\"{\"bonesHidden\":3,\"name\":\"Albert\",\"type\":\"Dog\"}\"\"\".parseJson)\n  assert(encodedAlbert.convertTo[Pet] == albert)\n}\n```\n\nThe discriminator can be customised by annotating the union type with the `@Discriminator` annotation:\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\nimport spray.json.derived.Discriminator\n\n@Discriminator(\"petType\")\nsealed trait Pet\ncase class Cat(name: String, livesLeft: Int)   extends Pet\ncase class Dog(name: String, bonesHidden: Int) extends Pet\n\nobject Test extends App {\n  val oliver: Pet   = Cat(\"Oliver\", 7)\n  val encodedOliver = oliver.toJson\n  assert(encodedOliver == \"\"\"{\"livesLeft\":7,\"name\":\"Oliver\",\"petType\":\"Cat\"}\"\"\".parseJson)\n  assert(encodedOliver.convertTo[Pet] == oliver)\n}\n```\n\n#### Recursive types\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\nsealed trait Tree\ncase class Leaf(s: String)            extends Tree\ncase class Node(lhs: Tree, rhs: Tree) extends Tree\n\nobject Test extends App {\n\n  val obj: Tree = Node(Node(Leaf(\"1\"), Leaf(\"2\")), Leaf(\"3\"))\n  val encoded   = obj.toJson\n  val expectedJson =\n    \"\"\"{\n      |  \"lhs\": {\n      |    \"lhs\": {\n      |      \"s\": \"1\",\n      |      \"type\": \"Leaf\"\n      |    },\n      |    \"rhs\": {\n      |      \"s\": \"2\",\n      |      \"type\": \"Leaf\"\n      |    },\n      |    \"type\": \"Node\"\n      |  },\n      |  \"rhs\": {\n      |    \"s\": \"3\",\n      |    \"type\": \"Leaf\"\n      |  },\n      |  \"type\": \"Node\"\n      |}\n      |\"\"\".stripMargin\n  assert(encoded == expectedJson.parseJson)\n  assert(encoded.convertTo[Tree] == obj)\n}\n```\n\n#### Polymorphic types\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\ncase class Container[T](value: T)\n\nobject Test extends App {\n\n  val cString: Container[String] = Container(\"abc\")\n  val cStringEncoded             = cString.toJson\n  assert(cStringEncoded == \"\"\"{\"value\":\"abc\"}\"\"\".parseJson)\n  assert(cStringEncoded.convertTo[Container[String]] == cString)\n\n  val cInt: Container[Int] = Container(123)\n  val cIntEncoded          = cInt.toJson\n  assert(cIntEncoded == \"\"\"{\"value\":123}\"\"\".parseJson)\n  assert(cIntEncoded.convertTo[Container[Int]] == cInt)\n}\n```\n\n#### Undefined optional members\n\nBy default, undefined optional members are not rendered:\n\n```scala\nimport spray.json._\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\ncase class Dog(toy: Option[String])\n\nobject Test extends App {\n  val aDog        = Dog(toy = None)\n  val aDogEncoded = aDog.toJson\n  assert(aDogEncoded.compactPrint == \"{}\")\n}\n```\n\nIt's possible to render undefined optional members as null values by specifying an alternative configuration.\nJust specify the alternative configuration as implicit value and enable the `renderNullOptions` flag:\n\n```scala\nimport spray.json._\nimport spray.json.derived.Configuration\nimport spray.json.derived.auto._\nimport spray.json.DefaultJsonProtocol._\n\ncase class Dog(toy: Option[String])\n\nobject Test extends App {\n\n  implicit val conf: Configuration = Configuration(renderNullOptions = true)\n\n  val aDog        = Dog(toy = None)\n  val aDogEncoded = aDog.toJson\n  assert(aDogEncoded.compactPrint == \"\"\"{\"toy\":null}\"\"\")\n}\n```\n\n## License\n\nspray-json-derived-codecs is licensed under [APL 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaoloboni%2Fspray-json-derived-codecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaoloboni%2Fspray-json-derived-codecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaoloboni%2Fspray-json-derived-codecs/lists"}