Hi,
Why is it that just when I need it, Groovy's "metaClass" property returns null. Example:
import net.sf.json.groovy.JsonSlurper
@Grab(group='net.sf.json-lib', module='json-lib', version='2.3', classifier='jdk15')
def printMeta(obj) {
obj.metaClass.properties.each {println "Property: ${it.name}"}
}
def raw = /{"test":"this is a test"}/
def json = new JsonSlurper().parseText(raw);
printMeta (json);
I know that JsonSlurper uses metaprogramming, so why do I get the following:
Caught: java.lang.NullPointerException: Cannot get property 'properties' on null object
at MetaTest.printMeta(MetaTest.groovy:17)
at MetaTest.run(MetaTest.groovy:24)
I'm all out of ideas.
Thanks!