Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (22 sloc) 627 Bytes
package groovy.runtime.metaclass.java.lang
import groovy.json.JsonSlurper
/**
* User: danielwoods
* Date: 7/18/13
*/
class StringMetaClass extends DelegatingMetaClass {
StringMetaClass(MetaClass meta) {
super(meta)
}
public Map toMap(String input) {
(Map)Eval.me(input)
}
public def toJson(String input) {
new JsonSlurper().parseText(input)
}
def invokeMethod(Object object, String method, Object[] args) {
if (method == "toMap") toMap(object)
else if (method == "toJson") toJson(object)
else super.invokeMethod(object, method, args)
}
}
You can’t perform that action at this time.