I am using version 0.32 of the JSON plugin with Struts 2.0.11. It seems
to work well except for the fact that the JSON results from my struts
action are inconsistent.
I have annotated my action as follows:
@Results( {
@Result(name = "jsonPopsResult", type = JSONResult.class, value =
"", params = {"root", "jsonResult", "noCache", "true"}),
@Result(name = "jsonRefugesResult", type = JSONResult.class, value
= "", params = {"root", "jsonResult", "noCache", "true"})})
public class MapQueryAction extends ActionSupport {
...
}
Sometimes the response generated by the action is (for example)
{"trustResources":[{"displayName":"Bull Trout","id":301}]}
at other times it is
{"jsonResult":{"trustResources":[{"displayName":"Bull
Trout","id":301}]}}
Note that the second response has an outer level of wrapping that
corresponds to the root parameter in the annotation (the action property
to be serialized).
I think (though am not 100% positive) that the change in behavior happens
when I restart my tomcat container, so this smells strongly of a class
loading problem. I've looked for duplicate jars/classes, but have come up
empty. In particular, I have only one json-plugin jar
(json-plugin-0.32.jar) in my application's WEB-INF/lib directory. Has
anyone else experienced this kind of problem with the JSON plugin?
Thanks,
Jim Greuel