You can use Jersey's built-in Json JSON library to automatically serialize JSON from any POJO classes. You just need to add the Jackson JSON library to your pom.xml:
<dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>${jersey.version}</version> </dependency>
Also, in order to activate the POJO Jersey display, you need to add the following lines to web.xml:
<init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value> </init-param>
Then, if your class method is EmployeeService().getEmployees() returns a list of employees, Jersey will serialize it to something like (JSON array)
{"employees": ["name":"Adam", "name":"Robert", ....]}
source share