Apache CXF uses Jettison for generating JSON generation. By default, Jettison adds the class name as well in JSON representation. To remove the class name from the json, there is some extra configuration required, which I will tell you some other time. Another solution to this problem is to use Jackson.
public class Error{ Integer code; String reason; /* * getters and setters */ }Jettison's JSON:
{ "error" : { code: "CODE", reason: "REASON } }
Jackson's JSON:
{ code: "CODE", reason: "REASON" }
Now I will explain how to tell CXF to use Jackson instead of Jettison. Following are the required steps: