Spring RESTful Webservice - Returning JSON without model object
<p>there.<br>
I have a doubt with returning JSONObjects on a Spring RESTful WebService.</p>

<p>Here it goes:<br>
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:</p>

<pre><code>HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No converter found for return value of type: class org.json.JSONObject
</code></pre>

<p>So, I actually understand what that means, and I've been searching a answer to that issue for at least 3 days.</p>

<p>Here is my code:</p>

<pre><code>@RequestMapping(value = "/value", method = RequestMethod.POST)
public String method(HttpServletRequest request) {
    JSONObject json = new JSONObject();
    json.put("example", "example message");

    return json.toString();
}
</code></pre>

<p>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 <strong>true</strong> JSONObject? Or returning a JSONObject.toString() should work fine?</p>

<p>And one last thing:<br>
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?</p>

<p>Thanks in advance, peeps!</p>