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