title: Spring MVC returning JSONS and exception Handling
body: <p>I am using Spring MVC with Controllers, my question is how do I return a JSON response which is different from the @ResponseBody object which is returned and convereted to a JSON to be returned.</p>
  
  <p>To elaborate further, I have the object called "UserDetails" which has two fields called "name", "emailAddress"</p>
  
  <pre><code>@ResponseBody UserDetails
  </code></pre>
  
  <p>now the json returned will look like </p>
  
  <blockquote>
    <p>{ name : "TheUsersName",
    emailAddress:"abc@abc123.com" }</p>
  </blockquote>
  
  <p>Is there any way I can modify the json before returning (ALL jsons in all methods across all controllers) where a "status" field will be added and the other json data will be under the "data" key in the json.</p>
  
  <p>Also how do I return a json to the frontend when the java server from somewhere throws an exception, the json should have "status : false" and the exception name (atleast the status part though)</p>