Reputation: 707
Is there any way to to this:
def getChannelListJSON = {
def results = Channel2.list()
def t1 = System.currentTimeMillis()
render(contentType:"text/json") {
canais = array {
for(b in results) {
canal = {
id= b.id
nome= b.channel_name
sigla= b.channel_sigla
}
}
}
}
def t2 = System.currentTimeMillis()
def tt = t2 - t1
new Statistic(servico: Servicos.findByName('getChannelListJSON'), totalTime: tt, date: new Date()).save()
}
but instead of using render, i need to use :
return object as XML
Because i need to turn this rest method compatible with http://code.google.com/p/grails-jaxrs/wiki/GettingStarted and i cannot ge it using render.
Upvotes: 0
Views: 495
Reputation:
Try:
JSONWithPadding getChannelListJSON(@DefaultValue("callback") @QueryParam("callback") String callback) {
GenericEntity genericEntity = new GenericEntity<Type>(var contains result, Type.class);
return new JSONWithPadding(genericEntity, callback);
}
Upvotes: 0
Reputation: 336
You would need to change the content type to "text/xml"
http://grails.org/doc/2.0.x/ref/Controllers/render.html
Upvotes: 1