title: Returning JSON object as response in Spring Boot
body: <p>I have a sample RestController in Spring Boot:</p>
  
  <pre><code>@RestController
  @RequestMapping("/api")
  class MyRestController
  {
      @GetMapping(path = "/hello")
      public JSONObject sayHello()
      {
          return new JSONObject("{'aa':'bb'}");
      }
  }
  </code></pre>
  
  <p>I am using the JSON library <a href="https://stleary.github.io/JSON-java/index.html" rel="noreferrer"><code>org.json</code></a></p>
  
  <p>When I hit API <code>/hello</code>, I get an exception saying : </p>
  
  <blockquote>
    <p>Servlet.service() for servlet [dispatcherServlet] in context with path
    [] threw exception [Request processing failed; nested exception is
    java.lang.IllegalArgumentException: No converter found for return
    value of type: class org.json.JSONObject] with root cause</p>
    
    <p>java.lang.IllegalArgumentException: No converter found for return
    value of type: class org.json.JSONObject</p>
  </blockquote>
  
  <p>What is the issue? Can someone explain what exactly is happening?</p>