Search code examples
scalascala.jsupickle

µPickle Couldn't derive type error on write


I'm trying to use µPickle in Scala.js to produce Json for Ajax request. Here is my code:

    import upickle._
    import upickle.default._
    case class FmData(name: String, comment: String)
    val data = write(FmData("name", "comment"))

And I get error:

Couldn't derive type FmData

How come?


Solution

  • The same issue happened to me before. It was happening when I was defining this case class in package object, other object or inside of method. However when I extracted it to a separate file, it was all fine and working.

    Hope it helps.