Right now I have hard coded it for json like the following code snippet.
@GET @Path("/{id}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Response getCustomer(@PathParam("id") String id) {
Customer c = null;
Response r = null;
if(id != null){
c = fetchCustomer(id);//fetchCustomer will return the customer with id
Builder ob = Builder.create(c);
r = Response.ok(ob.deliver(),MediaType.APPLICATION_JSON).build();
}
else{
r = Response.status(400).build();
}
return r;
}
How can I remove the hard coding and give the result in desired format?