Grails JSON array

后端 未结 4 2171
遇见更好的自我
遇见更好的自我 2021-02-08 03:18

I\'m converting a list of Foo objects to a JSON string. I need to parse the JSON string back into a list of Foos. However in the following example, parsing gives me a list of JS

4条回答
  •  滥情空心
    2021-02-08 03:36

    As of Grails 2.5, this is possible:

    Period test = new Period()
    test.periodText = 'test'
    String j = test as JSON
    def p = JSON.parse(j)
    test = p.asType(Period)
    println(test.periodText)
    

    Output:

    test
    

    I am unsure of when it became an option.

提交回复
热议问题