I'm trying something simple with Groovy and JSON-lib:
import net.sf.json.*
def fromList = "[{name:'scott'}, {name:'mike'}]" as JSONArray
however I am getting this error:
Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[{name:'scott'}, {name:'mike'}]' with class 'java.lang.String' to class 'net.sf.json.JSONArray'
at test.run(test.groovy)
at test.main(test.groovy)
Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Starting from 2.2.1 custom metaClasses are no loner registered at startup, you'll have to call
net.sf.json.groovy.GJson.enhanceClasses()
before attempting groovy casting.
I thought the info was on the site but the gapi docs are missing, I'll make sure the docs get
updated.
Cheers,
Andres
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying something simple with Groovy and JSON-lib:
import net.sf.json.*
def fromList = "[{name:'scott'}, {name:'mike'}]" as JSONArray
however I am getting this error:
Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[{name:'scott'}, {name:'mike'}]' with class 'java.lang.String' to class 'net.sf.json.JSONArray'
at test.run(test.groovy)
at test.main(test.groovy)
Any ideas?
Scott,
Starting from 2.2.1 custom metaClasses are no loner registered at startup, you'll have to call
net.sf.json.groovy.GJson.enhanceClasses()
before attempting groovy casting.
I thought the info was on the site but the gapi docs are missing, I'll make sure the docs get
updated.
Cheers,
Andres