I am trying to get json response from Postgresql database(v9.5) table to display on my view page, I have tried the following, as my application is executing fine, but I am not getting/displaying my required proper json data(as it is containing: Stream, slashes() and question mark(?), like Stream type json). Please let me know that how to show my desired output like below ? my output:
Stream("[{\"_testid\":{\"testid0\":\"testnumber\"},\"testtitle\":\"TestTitle\"}]", ?)
but my desired output:
[{"_testid":{"testid0":"testnumber"},"testtitle":"TestTitle"}]
contorller:
class Test extends Controller {
def getTest = Action {
var sql: SqlQuery = SQL("select name::TEXT from test");
def values: String = DB.withConnection { implicit connection =>
sql().map(row => row[String]("name")).toString
}
Ok(values)
}
table:
create table test(
id serial primary key,
name json not null);