Changing the standard REST response to JSON instead of XML
I'm new to Java REST, I'm currently confused with the response I get from POSTMAN, or Chrome is always defaulted to XML and can't change it to JSON unless I remove the XML part. I am using Jersey 2, Netbeans and Glassfish 4.1.1 / 4.1
This returns XML
@Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
This will only return JSON
@GET
@Path("loc/{lat}/{long}")
@Produces({MediaType.APPLICATION_JSON})
@SuppressWarnings("unchecked")
//@Produces({MediaType.TEXT_PLAIN})
public List<Lastknown> findNearMeLastKnown(@PathParam("lat") String lat, @PathParam("long") String longitude) {
//List<Lastknown> results =;
return super.findNearMeLastKnown(lat,longitude);
}
+3
source to share