Grails JSON array

Posted by armandino on Stack Overflow See other posts from Stack Overflow or by armandino
Published on 2010-04-20T00:06:52Z Indexed on 2010/04/20 0:13 UTC
Read the original article Hit count: 991

Filed under:
|
|

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 JSONObjects instead of Foos.

Example

List list = [new Foo("first"), new Foo("second")]
def jsonString = (list as JSON).toString()

List parsedList = JSON.parse(jsonString) as List
println parsedList[0].getClass() // org.codehaus.groovy.grails.web.json.JSONObject

How can I parse it into Foos instead? Thanks in advance.

© Stack Overflow or respective owner

Related posts about grails

Related posts about groovy