Skip to content

Instantly share code, notes, and snippets.

@d3ep4k
Created May 22, 2019 07:34
Show Gist options
  • Save d3ep4k/fd23ebcdcaaca485dcce99442e8822b2 to your computer and use it in GitHub Desktop.
Save d3ep4k/fd23ebcdcaaca485dcce99442e8822b2 to your computer and use it in GitHub Desktop.
GroovyScriptEngine engine = new GroovyScriptEngine(".");
Map<String, String> request = new HashMap();
request.put("param1", "Hello");
Map<String, String> response = new HashMap();
response.put("param1", "World");
Binding binding = new Binding();
binding.setVariable("request", request);
binding.setVariable("response", response);
engine.run("src/main/java/"+className, binding);
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Configuration;
String json = "{\"user\":\"deepak\"}";
Object document = Configuration.defaultConfiguration().jsonProvider().parse(json);
println JsonPath.read(document, "\$.user");
def makethiswork(request, response){
return request.param1 + ' ' + response.param1;
}
response.param1 = makethiswork(request, response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment