Running a Play! app with Scala. I'm doing a request where the response is expected to be a JSON string. When checking the debugger, the JsonElement returns OK with all information as expected. However, the problem is when I try to actually run methods on that JsonElement.
val json = WS.url("http://maps.googleapis.com/maps/api/geocode/json?callback=?&sensor=true&address=%s", startAddress+","+startCity+","+startProvince).get.getJson val geocoder = json.getAsString
The only error I get back is Unsupported Operation Exception: null and I've tried this on getAsString and getAsJsonObject and getAsJsonPrimitive
Unsupported Operation Exception: null
getAsString
getAsJsonObject
getAsJsonPrimitive
Any idea why it's failing on all methods? Thanks.
Maybe your JsonElement is a JsonNull
JsonElement
JsonNull
What you could do is to first check that it isn't by using json.isJsonNull
json.isJsonNull
Otherwise, try to get its String representation with json.toString
json.toString
2.1m questions
2.1m answers
60 comments
57.0k users