EindbaasExpress / handsonscala-issuemigrator

Part of the HandsOnScala Course
0 stars 0 forks source link

uPickle does not know how to write [...] #78

Open EindbaasExpress opened 2 years ago

EindbaasExpress commented 2 years ago

Hi!

While looking for a nice way to pickle scala objects <-> json to exchange data between play and scala-js enabled client, uPickle seems a good candidate.

Unfortunately, until now I kept getting the error "uPickle does not know how to write..." while trying to picklelise a custom case class (like the 'Thing' example given on the main page) on the JVM (didn't even tried with scalajs).

Finally, I discovered the source of the issue: the version of scala. While compiling with scala 2.10.4, the message keep popping up, however when using scala 2.11.x it compiles gently.

The configuration is as simple as possible, a standalone sbt project with only one libraryDependency (uPickle), and a single file:

case class Buddy(a: Int)
import upickle._

object Blah {
  def blah = {
    write(Buddy(42))
  }
}

As a side note, uPickle < 0.2.0 works with 2.10.x (e.g. 0.1.6), not uPickle >= 0.2.0.

Cheers,

Jean Luc

ID: 20 Original Author: jlc