there.
I have a doubt with returning JSONObjects on a Spring RESTful WebService.
Here it goes:
I have a method in my controller which I want to have it returning a JSONObject. However, when I set it's return type to JSONObject and effectively return a JSONObject, I get that following error:
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class org.json.JSONObject
So, I actually understand what that means, and I've been searching a answer to that issue for at least 3 days.
Here is my code:
@RequestMapping(value = "/value", method = RequestMethod.POST)
public String method(HttpServletRequest request) {
JSONObject json = new JSONObject();
json.put("example", "example message");
return json.toString();
}
I trully don't know if that's gonna work when I have to consume it on the front-end (Which is going to be an external application). Do I have to return a true JSONObject? Or returning a JSONObject.toString() should work fine?
And one last thing:
Most tutorials about returning a JSONObject teaches that proccess using a model object, which I don't want to use. Is there a way of doing that without using a model object?
Thanks in advance, peeps!