- Talk: https://www.youtube.com/watch?v=dKblZynnhgo
- Slides: https://nicolasstucki.github.io/scala-days-2023/
This is a normal sbt project. You can compile code with sbt compile, test it with sbt test, and sbt console will start a Scala 3 REPL.
type Json = JsonObject | JsonArray | Double | String | Boolean | NullThe string interpolator json defined in JsonStringContext.scala provides shows how to implement the interpolator apply and unapply with macros.
val user = json"""{
"firstName": "John",
"lastName": "Doe"
}"""
val bool = json"true"
val account = json"""{
"user": $user,
"active": $bool
}"""where the type of account is refined to
account: JsonObject {
val user: JsonObject {
val firstName: String
val lastName:String
}
val active: Boolean
}(account: Json) match
case json"""{ "user": $x, "active": true }""" => println(x + " is active")
case _ =>