My restful API method looks like this
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getMessage()
{
FreeDriversService f=new FreeDriversService();
try {
return f.executeFreeDrivers(); // this method return a JSONArray
}
catch(Exception e) {
System.out.println(e.toString());
return new JSONArray();
}
}
When I use the toString()
method on JSONArray
it does produce a result, but I would like JSON
as output. How can i do that?
I am getting this error
A message body writer for Java class org.json.JSONArray, and Java type class org.json.JSONArray, and MIME media type application/json
was not found