import grails.converters.JSON
class User{
String nickname
Integer age
}
class TestController{
def listAsJson = {
def output = "{'nickname':'东瓜','age':'16'}"
render output as JSON
}
def listAsJSON2 = {
def output = "{'nickname':'东瓜','age':'16'}"
render JSON.parse(output)
}
def listAsJSON3 = {
def user = User.get(1)
render user as JSON
}
def listAsJSON4 = {
def outputMap = ['1':1,'2':2]
render outputMap as JSON
}
}
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
小宝很社会