I am new to Scala and play 2 and haven't found a way to return a Json request from the database using Anorm. This is my simple code
def locations = Action {implicit c=>
import play.api.libs.json._
implicit val readLocations = SQL("select city,state from zips limit 1")
Ok(Json.toJson(readLocations))
}
The method is a post I simply want to return via Json 1 record from the database table there but I get this error Error:(57, 21) Play 2 Compiler: .scala:57: No Json serializer found for type anorm.SqlQuery. Try to implement an implicit Writes or Format for this type. Ok(Json.toJson(readLocations))
Any suggestions would be welcomed, I have been switching the code above some but nothing is working. I know I need to do a Write or Format but can't seem to find out how.
^**
Reads
orFormat
of that type). By the way, reading Play docs concerning JSON is highly recommended.