Play Framework WS: Returning JSON data as Int Play Framework WS: Returning JSON data as Int json json

Play Framework WS: Returning JSON data as Int


What this message is telling you is that the JSON your providing is not parseable in the type you expect.

The first one is about Some(data.value(0).as[JsArray].value(0).as[Int]). apparently data.value(0).as[JsArray].value(0) is not a Number, and therefore can't be converted to an Int.

For the second one, val data = (response.json \ "data").as[JsArray] since the id does not exist, apparently the Json you get has no key 'data', or the value at that key is not an array (null ?).

I suggest you log the value of r.json before parsing. You'll see exactly why it's failing.You should also avoid using as and use validate instead (http://www.playframework.com/documentation/2.1.2/ScalaJsonRequests).