1

I'm currently working on making an Struts 2 Action call with a JSON response - I'd like to have the response be cache-able, which means I need to get the JSON generated within the code before the call is made. Something like this, within and action's execute() method:

String json = this.getJSONOutput();
JSONCacheUtils.cache(hash, json);

Is there any way to do this using the Struts 2 JSON library?

Roman C
  • 49,761
  • 33
  • 66
  • 176
jtyler
  • 1,055
  • 2
  • 15
  • 22

1 Answers1

1

You can use Struts2 JSON plugin API to serialize object. The same way JSONResult is doing when it's executed.

String json = JSONUtil.serialize(rootObject, excludeProperties, includeProperties, ignoreHierarchy, enumAsBean, excludeNullProperties);
Roman C
  • 49,761
  • 33
  • 66
  • 176