Replies: 1 comment 1 reply
-
Hi @exoego, sorry for the long response time. I'm afraid that currently //> using scala "3.1.1"
//> using lib "org.virtuslab::scala-yaml:0.0.4"
//> using lib "com.lihaoyi::pprint:0.7.3"
import org.virtuslab.yaml.*
object Yamltest extends App {
case class User(name: String, `user-type`: Option[String]) derives YamlDecoder
val yaml =
s"""
|user1:
| name: John
| user-type:
|user2:
| name: Jane
| user-type: Admin
|""".stripMargin
pprint.log(yaml.as[Map[String, User]])
}
Yaml.scala:21 yaml.as[Map[String, User]]: Right(
value = Map(
"user1" -> User(name = "John", user-type = None),
"user2" -> User(name = "Jane", user-type = Some(value = "Admin"))
)
) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given
results in
Left(ConstructError(Key user-type doesn't exist in parsed document))
I would like to decode missing key as Option.
Beta Was this translation helpful? Give feedback.
All reactions