I want to parse Text to json in groovy script
but get errors:
failed to load/compile script [my_script]
This is my_script.groovy file:
d=doc['data'].value
//d='data=%7B%22request%22%3A%7B%22model%22%3A%22Score%22%2C%22action%22%3A%22getSignInScoreEx%22%2C%22parameters%22%3A%7B%22uid%22%3A%22108043431%22%7D%7D%7D'
//path='request.parameters.uid'
//val='108043431'
ebody=d.substring(5);
body=java.net.URLDecoder.decode(ebody,"UTF-8");
json=new groovy.json.JsonSlurper().parseText(body);
paths=path.split('\.')
obj = json
for(String p : paths) {
obj=obj[p]
}
if(obj==val) {
return true
} else {
return false
}
after some debug,problem may comes from "json=new groovy.json.JsonSlurper().parseText(body);"
anyone can help me? thx
(ElasticSearver version: 2.4.1)