grails处理json数据

2015-12-14 0 686
grails处理json数据
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
   }
}

遇见资源网 groovy grails处理json数据 http://www.ox520.com/13759.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务