{"id":13800808,"url":"https://github.com/sparsetech/toml-scala","last_synced_at":"2025-05-13T09:31:55.684Z","repository":{"id":55833748,"uuid":"109728634","full_name":"sparsetech/toml-scala","owner":"sparsetech","description":"TOML parser with codec derivation for the Scala platform","archived":true,"fork":false,"pushed_at":"2024-10-24T17:24:06.000Z","size":77,"stargazers_count":27,"open_issues_count":5,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T23:45:22.497Z","etag":null,"topics":["scala","scala-native","scalajs","shapeless","toml"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/sparsetech.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":"2017-11-06T17:40:52.000Z","updated_at":"2024-10-24T17:28:19.000Z","dependencies_parsed_at":"2024-11-18T15:52:36.862Z","dependency_job_id":null,"html_url":"https://github.com/sparsetech/toml-scala","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Ftoml-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Ftoml-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Ftoml-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparsetech%2Ftoml-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparsetech","download_url":"https://codeload.github.com/sparsetech/toml-scala/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913244,"owners_count":21983284,"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":["scala","scala-native","scalajs","shapeless","toml"],"created_at":"2024-08-04T00:01:16.480Z","updated_at":"2025-05-13T09:31:53.903Z","avatar_url":"https://github.com/sparsetech.png","language":"Scala","funding_links":[],"categories":["File Formats and Parsers","TOML"],"sub_categories":["PHP - Docblock Parser"],"readme":"# toml-scala\n[![Build Status](https://travis-ci.org/sparsetech/toml-scala.svg)](https://travis-ci.org/sparsetech/toml-scala)\n[![Build Status](http://ci.sparse.tech/api/badges/sparsetech/toml-scala/status.svg)](http://ci.sparse.tech/sparsetech/toml-scala)\n[![Maven Central](https://img.shields.io/maven-central/v/tech.sparse/toml-scala_2.12.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22tech.sparse%22%20AND%20a%3A%22toml-scala_2.12%22)\n\ntoml-scala is a feature-complete implementation of [TOML](https://github.com/toml-lang/toml) for the Scala platform. It can parse TOML content into an AST or map it onto `case class` hierarchies. Furthermore, it can generate TOML back from an AST.\n\n## Status\nThis library is no longer maintained. Please switch to [this fork](https://github.com/indoorvivants/toml-scala) maintained by Indoor Vivants, which adds support for Scala 3.\n\n## Features\n- Standard-compliant\n- AST parsing\n- Codec derivation\n    - Optional values\n    - Custom codecs\n- Generating TOML from ASTs\n- Error handling\n- Property-based unit tests\n\n## Compatibility\n| Back end   | Scala versions    | Date support | Tests         |\n|:-----------|:------------------|:-------------|:--------------|\n| JVM        | 2.11, 2.12, 2.13  | Yes          | Yes           |\n| JavaScript | 2.11, 2.12, 2.13  | No (1)       | Yes           |\n| LLVM       | 2.11              | No (1)       | Partially (2) |\n\n* (1) JavaScript and LLVM have insufficient support for the JDK8's `java.time`. Parsing of dates and times is presently only possible under the JVM.\n* (2) Presently, Scala Native does not support running ScalaCheck test suites.\n\n### Dependencies\n```scala\nlibraryDependencies += \"tech.sparse\" %%  \"toml-scala\" % \"\u003cversion\u003e\"  // JVM\nlibraryDependencies += \"tech.sparse\" %%% \"toml-scala\" % \"\u003cversion\u003e\"  // JavaScript, LLVM\n```\n\n## Examples\n### AST parsing\n```scala\ntoml.Toml.parse(\"a = 1\")  // Right(Tbl(Map(a -\u003e Num(1))))\n```\n\n### Codec derivation\nThe following import is needed:\n\n```scala\nimport toml.Codecs._\n```\n\n#### Tables\n```scala\ncase class Table(b: Int)\ncase class Root(a: Int, table: Table)\n\nval table =\n  \"\"\"\n    |a = 1\n    |[table]\n    |b = 2\n  \"\"\".stripMargin\n\nToml.parseAs[Root](table)  // Right(Root(1, Table(2)))\n```\n\n#### Table lists\n```scala\nval tableList =\n  \"\"\"\n    |points = [ { x = 1, y = 2, z = 3 },\n    |           { x = 7, y = 8, z = 9 },\n    |           { x = 2, y = 4, z = 8 } ]\n  \"\"\".stripMargin\n\ncase class Point(x: Int, y: Int, z: Int)\ncase class Root(points: List[Point])\n\nToml.parseAs[Root](tableList)\n// Right(Root(List(\n//   Point(1, 2, 3),\n//   Point(7, 8, 9),\n//   Point(2, 4, 8))))\n```\n\nLists can be mapped onto `case class`es as a shorter alternative. Therefore, the following notation would yield the same result:\n\n```toml\npoints = [ [ 1, 2, 3 ],\n           [ 7, 8, 9 ],\n           [ 2, 4, 8 ] ]\n```\n\n#### Optional values\n```scala\ncase class Table(b: Int)\ncase class Root(a: Int, table: Option[Table])\n\nToml.parseAs[Root](\"a = 1\")  // Right(Root(1, None))\n```\n\n#### Define custom codecs\n```scala\ncase class Currency(name: String)\nimplicit val currencyCodec: Codec[Currency] = Codec {\n  case (Value.Str(value), _, _) =\u003e\n    value match {\n      case \"EUR\" =\u003e Right(Currency(\"EUR\"))\n      case \"BTC\" =\u003e Right(Currency(\"BTC\"))\n      case _     =\u003e Left((List(), s\"Invalid currency: $value\"))\n    }\n\n  case (value, _, _) =\u003e Left((List(), s\"Currency expected, $value provided\"))\n}\n\ncase class Root(currency: Currency)\nToml.parseAs[Root](\"\"\"currency = \"BTC\"\"\"\")  // Right(Root(Currency(BTC)))\n```\n\n#### Generate TOML\n```scala\nval root = Root(List(Pair(\"scalaDeps\", Arr(List(\n  Arr(List(Str(\"io.monix\"), Str(\"minitest\"), Str(\"2.2.2\"))),\n  Arr(List(Str(\"org.scalacheck\"), Str(\"scalacheck\"), Str(\"1.14.0\"))),\n  Arr(List(Str(\"org.scalatest\"), Str(\"scalatest\"), Str(\"3.2.0-SNAP10\")))\n)))))\n\nToml.generate(root)\n```\n\nReturns:\n\n```toml\nscalaDeps = [\n  [\"io.monix\", \"minitest\", \"2.2.2\"],\n  [\"org.scalacheck\", \"scalacheck\", \"1.14.0\"],\n  [\"org.scalatest\", \"scalatest\", \"3.2.0-SNAP10\"]\n]\n```\n\n#### Language Extensions\ntoml-scala supports the following language extensions which are disabled by default:\n\n* [New lines and trailing commas in inline tables](https://github.com/toml-lang/toml/issues/516)\n\nTo enable them, pass in a set of extensions to the `parse()` or `parseAs()` function as a second argument:\n\n```scala\ntoml.Toml.parse(\"\"\"key = {\n  a = 23,\n  b = 42,\n}\"\"\", Set(toml.Extension.MultiLineInlineTables))\n```\n\n## Links\n* [ScalaDoc](https://www.javadoc.io/doc/tech.sparse/toml-scala_2.12/)\n\n## Licence\ntoml-scala is licensed under the terms of the Mozilla Public Licence v2.0.\n\n## Credits\nThe rules and their respective tests were derived from [stoml](https://github.com/jvican/stoml) by Jorge Vicente Cantero.\n\ntoml-scala is based on top of [FastParse](https://github.com/lihaoyi/fastparse) for defining the language rules. [ScalaCheck](https://github.com/rickynils/scalacheck) allows us to test synthetic examples of TOML files. The codec derivation was implemented using [Shapeless](https://github.com/milessabin/shapeless).\n\n## Contributors\n* Tim Nieradzik\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsetech%2Ftoml-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparsetech%2Ftoml-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparsetech%2Ftoml-scala/lists"}