1

I'm trying ScalaJS with Play! Scala 2.4 and the serialization library for Scala uPickle.

I don't manage to parse the return of an AJAX call.

Here is my case class:

@JSExportAll
case class Room(id: String, name: String, presentation: String, images: Seq[String], isAnApartment: Boolean )

I have a controller on the server side returning a sequence of rooms:

 val rooms = Seq(room1, room2, room3)
 def findAll() = Action {
   Ok(write(rooms))
 } 

(Rooms are some instance of the Room class.)

Now I want to deserialize these object on the client side. Here is the snippet of code which does not work:

Ajax.get("/rooms")
  .onSuccess { case response =>
     read[Seq[Room]](response.responseText)
  }

but I get this runtime exception:

RuntimeException: There were linking errors

What I want to do seems very easy but I don't manage to make it work, any hints would be appreciated.

Simon
  • 6,025
  • 7
  • 46
  • 98
  • Hmm. Where are you getting that error from? What are you doing when it's happening? That's a JVM error as far as I know -- where are you seeing the error? (Actually, it looks like that error sometimes happens when you try to use JVM-only code in Scala.js. Do you have a repo with the full code?) – Justin du Coeur Nov 26 '15 at 20:09
  • The "There were linking errors" should be accompanied by a "Trying to reach blablabla" and a sort-of-stack trace. Could you please paste them in your question? Without that it's impossible to help you. – sjrd Nov 26 '15 at 21:24
  • 1
    Educated guess: did you make sure to use `%%%` in your dependency on uPickle, and not `%%`? – sjrd Nov 26 '15 at 21:26
  • Ok thanks srjd ! The problem was indeed that I used %% instead of %%% in my depencies. – Simon Nov 27 '15 at 15:28

0 Answers0