Table of Contents

Typesafe config 🔗

Tupson integrates with the awesome Typesafe config library.

You will need to add this dependency:

            ba.sake::tupson-config:0.16.1 // scala-cli

mvn"ba.sake::tupson-config:0.16.1" // mill

"ba.sake" %% "tupson-config" % "0.16.1" // sbt


          

Real-world example in sharaf-petclinic

Usage 🔗

You can call .parseConfig[MyConf] function on a Config to parse it to the desired type:

            import java.net.URL
import com.typesafe.config.ConfigFactory
import ba.sake.tupson.{given, *}
import ba.sake.tupson.config.*

case class MyConf(
  port: Int,
  url: URL,
  string: String,
  seq: Seq[String]
) derives JsonRW

val rawConfig = ConfigFactory.parseString("""
  port = 7777
  url = "http://example.com"
  string = "str"
  seq = [a, "b", c]
""")

val myConf = rawConfig.parseConfig[MyConf]
// MyConf(7777,http://example.com,str,List(a, b, c))