Spring rest api filter fields in the response
<p>I am using spring rest api 4.x. We have a requirement to filter the fields in the response based on the request parameters.</p>

<p>My User object:</p>

<pre><code>private class UserResource {
   private String userLastName;
   private String userFirstName;
   private String email;
   private String streetAddress;
}

E.g. URL:  curl -i http://hostname:port/api/v1/users?fields=firstName,lastName. 
</code></pre>

<p>In this case I need to return only the fields which are in the request param "fields". JSON output should contain only firstName, lastName.</p>

<p>There are several ways filter the fields in Jackson based on the object. In my case I need to filter dynamically by passing the list of fields to Jackson serializer.</p>

<p>Please share some ideas.</p>