I use the following code to render data in JSON format.
render(contentType:"text/json") {
results = array {
db.eachRow(query) { row ->
def rs = row.toRowResult()
def a = b(rs.name,c,d)
aMap.put("A",a)
pair(aMap)
}
}
if (results) {
status = "OK"
}
else {
status ="Nothing present"
}
}
The above code generates JSON in the following format
{
"results": [
{"A":"value1"},
{"A":"value2"},
...................
{"A":"valuen"}
],
"status":"OK"
}
As u see above, the data is rendered as an array of objects. Is there a way I can render the results data as an array of elements. Like
{
"results": [
"value1",
"value2",
...................
"valuen"
],
"status":"OK"
}