object Protocol {
object GetSuggestions {
case class MyRequest(search: String, prefixOnly: Option[Boolean] = None)
object MyRequest {
//implicit val codec = io.circe.generic.semiauto.deriveCodec[MyRequest]
implicit val codec2: ReadWriter[MyRequest] = macroRW[MyRequest]
}
case class MyResponse(suggestions: Seq[String])
object MyResponse {
//implicit val codec = io.circe.generic.semiauto.deriveCodec[MyResponse]
implicit val codec2: ReadWriter[MyResponse] = macroRW[MyResponse]
}
}
}
val arg: Future[Response[Either[String,String]]] = req.send()
dom.console.log("made request")
dom.console.log(arg)
val uhOh: Future[Either[String,MyResponse]] = arg.map(_.body.map{
b => dom.console.log("-->" + b);
val test = Try(read[MyResponse](b))
println(test)
read[MyResponse](b)}
)
dom.console.log("Exception thrown before this message")
[Log] -->"{\"suggestions\":[\"apple\",\"pear\",\"orange\",\"strawberries\",\"orangutan\"]}" (dev.js, line 15780)
[Log] Failure(upickle.core.AbortException: expected dictionary got string at index 0) (dev.js, line 56688)
As far as I can tell, pickle is correctly "writing" the json. However, it fails to re-parse it coming back the other way, in scala JS.
I have an experiment in which I'm attempting to use upickle to pass Json between client / server...
As far as I can tell, pickle is correctly "writing" the json. However, it fails to re-parse it coming back the other way, in scala JS.
Would this be expected? ID: 352 Original Author: Quafadas