Skip to content

Missing keys exception using Option with generic #545

@mobilemindtec

Description

@mobilemindtec

Hello!

I'm getting a missing keys exception when key is a option generic field. Example:

case class Person(id: Int, name: String = "test") derives ReadWriter

case class Person2(id: Int, name: Option[String] = None) derives ReadWriter

case class ApiResult[T](data: Option[T] = None, @key("total_count") totalCount: Int) derives ReadWriter

println(read[Person]("{\"id\":1}"))  // OK

println(read[Person2]("{\"id\":1}"))  // OK

println(read[ApiResult[Person]]("{\"total_count\": 10}")) // Fail

Is there a way to get around this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions