在Grails中将地图渲染为json [英] Render map as json in Grails

查看:56
本文介绍了在Grails中将地图渲染为json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用程序使用Grails,但是JSON转换器有问题.

I'm using Grails for my application, and I have a problem with JSON converters.

在我的控制器中,我有:

In my controller, I have:

def myObject = [:]
myObject.key = 'value'
render ???

从控制器将 myObject 呈现为JSON的最佳方法是什么?

what is optimal way to render myObject as JSON from the controller?

推荐答案

很简单:

render (myObject as JSON)

render ([key: "value"] as JSON)

这篇关于在Grails中将地图渲染为json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆