I am using Jersey to implement a REST service. I want to display JSON on the browser but instead i get XML.
@Path("/todos")
public class TodosResource {
// Allows to insert contextual objects into the class,
// e.g. ServletContext, Request, Response, UriInfo
@Context
UriInfo uriInfo;
@Context
Request request;
// Return the list of todos to the user in the browser
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public List<Todo> getTodosBrowser() {
List<Todo> todos = new ArrayList<Todo>();
todos.addAll(TodoDao.instance.getModel().values());
return todos;
}
I Appreciate your help.