YamlConstructor
shampoo.yaml.YamlConstructor
@FunctionalInterface
Defines YAML constructor.
import scala.language.implicitConversions
import shampoo.yaml.{ *, given }
case class User(id: Int, name: String)
// Define how to construct User from YAML
given YamlConstructor[User] =
yaml => User(yaml("id"), yaml("name"))
val yaml = Yaml.load("{ id: 1000, name: lupita }")
// Construct and verify
val user = yaml.as[User]
assert(user.id == 1000)
assert(user.name == "lupita")
Attributes
- See also
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
In this article