I need to exclude fields before a JSON response is sent, depending on the logged in user. Concretely I have [user]s belonging to [company]s.
If the logged-in-user is an administor, he/she should be able to see all companies with all users. If the user is not an administrator he/she should be able to see all companies and the list of users of his/her company, but not the userlist of foreign companies. Therefore i have to filter the result list not only dynamically but also selectively.
I have already found this thread: How do I exclude fields with Jackson not using annotations? and this thread: Jackson Change JsonIgnore Dynamically
Is there a way to iterate through the result set to remove certain fields?