I have one table User details Table and it contains below Columns
User id,username,Email
I want to select email whose user id is 1 and i want the response as in proper JSON Format
How to do that In Scala Play 2.6 with Slick
Till now I have done this
def getPasswqord(username:String):Future[Seq[(String)]]= {
val a2 = (sql"""select a.userpassword from user_details_table a where a.Email=$username or a.Mobile_no=$username""".as[(String)])
dbConfig.run(a2)
}
from this i am getting response in a format "["12345"]"
.
Expected output format is
"[{"Password":"12345"}]"
You should define custom Json Writes to format your query result. For example:
This will output json object
[{"password":"12345"},{"password":"qwerty"}]