0

In an interceptor I have this code:

render(contentType: 'text/json') {
  msg 'Message to show'
}

It is not possible to add the @CompileStatic annotation on this interceptor, as the msg variable isn't declared. Is there any way to write this in a "compilestatic" friendly way?

Yuri
  • 4,254
  • 1
  • 29
  • 46
user3728821
  • 35
  • 1
  • 5

1 Answers1

0

Use the json builder directly

def json = new JsonBuilder()
json.call([msg: 'Message to show'])

render(text: json.toString(), contentType: 'text/json')
James Kleeh
  • 12,094
  • 5
  • 34
  • 61