title: Return mocked up JSON from file (JSONObject) in Spring Controller
body: <p>I'd like to mock up some JSON (that I'm reading from a file), and return it as a result of some Spring Controller.</p>
  
  <p>File contains of course correct JSON data format inside, like:</p>
  
  <pre><code>{"country":"","city":""...}
  </code></pre>
  
  <p>My controller looks like:</p>
  
  <pre><code>@RestController
  @RequestMapping("/test")
  public class TestController {
  
      @Value("classpath:/META-INF/json/test.json")
      private Resource testMockup;
  
      @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
      public @ResponseBody JSONObject getTest() throws IOException {
          JSONObject jsonObject = new JSONObject(FileUtils.readFileToString(testMockup.getFile(), CharEncoding.UTF_8));
          return jsonObject;
      }
  }
  </code></pre>
  
  <p>There is no issue with reading the file itself etc.
  <code>jsonObject</code> itself, is correct from debbuging PoV, however I'm getting <em>HTTP Status 406</em> from the browser.
  I've tried also just returning String (by returning <code>jsonObject.toString()</code>), instead of <code>JSONObject</code>.
  However it causes encoding issue - so that JSON from the browser, is not the JSON itself (some additional slashes, quotation marks etc.).</p>
  
  <p>Is there any way, to return JSON from file?</p>