【发布时间】:2016-03-16 22:34:21
【问题描述】:
我正在尝试输出一些简单的东西,例如 {"error": "endpoint not available"}
下面的 sn-p 以内容类型 text/html 呈现:
render ([error: 'endpoint not available']) as JSON
我也试过了:
render(contentType: 'application/json') {
error {
"endpoint not available"
}
}
我知道它不会产生所需的 JSON。
如何使用 application/json 内容类型生成我想要的 JSON?
【问题讨论】: