title: Dynamic JSON Object using responce entity - Spring
body: <p>I am using return ResponseEntity of Spring to return HTTP response.</p>
  
  <p>While passing POJO or MAP in entity, it converts that to JSON Object. Like</p>
  
  <pre><code>  return new ResponseEntity&lt;Object&gt;(result, HttpStatus.OK);
  </code></pre>
  
  <p>result may be POJO class. (getter and setters)</p>
  
  <p>I am using </p>
  
  <pre><code> &lt;bean id="jsonMessageConverter" class="org.springframework.http.converter.json.GsonHttpMessageConverter "&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Now what i want is, i will get a list of response fields in request. I just want to response the request with those fields only.</p>
  
  <p>For Ex, if i receive the response fields as name,id. Then the object must contain those two only.</p>
  
  <pre><code> {
   "name":"test",
   "id":15
   }
  </code></pre>
  
  <p>i can't able to use @jsonignore or @explore annotations. B'Coz i want the JSON to be done dynamically using coding. </p>
  
  <p>May be by overriding the GSON convertor methods or using AOP.  </p>
  
  <p>Is there any way to configure the adapter of jackson to create the object based on the fields.</p>