Forum Discussion
Anonymous
4 years agoYes, you can write JSON content to a cached token since you can write any string object. I'm not sure what the character limit might be.
def scriptCache scriptCache = this.class.classLoader.loadClass("com.santaba.agent.util.script.ScriptCache").getCache(); String token = scriptCache.get("myjson"); if(token == null){ //the token is empty because it has not been set previously //generate the json and set it into a token def json = JsonOutput.toJson([name: 'John Doe', age: 42]) assert json == '{"name":"John Doe","age":42}' scriptCache.set("myjson", json); } else{ //the json has been stored in the cache previously, so let's use it println(token) }
Related Content
- 6 months ago
- 2 years ago