user48956
user48956

Reputation: 15810

What magic needed to use scala uPickle?

I'm trying to following the quickstart guide here https://lihaoyi.github.io/upickle-pprint/upickle/

Have set the dependency

"com.lihaoyi" %%% "upickle" % "0.3.6",

but the basics seem to fail:

scala> import upickle.default._

import upickle.default._

scala> write(1)       
java.lang.ClassCastException: java.lang.Double cannot be cast to scala.scalajs.js.Any
  at upickle.json.package$.write(package.scala:38)
  at upickle.Types$class.write(Types.scala:125)
  at upickle.default$.write(Api.scala:25)
  ... 35 elided

Upvotes: 0

Views: 561

Answers (1)

Li Haoyi
Li Haoyi

Reputation: 15812

If you're using it in the REPL, you should use the non-scala.js version of the dependency:

"com.lihaoyi" %% "upickle" % "0.3.6",

Because the REPL runs on Scala-JVM, not Scala.js

Upvotes: 4

Related Questions