java - How to customize json response generated by Spring HttpMessageConverters -
i creating rest webservice using spring @restcontroller , httpmessageconverter.
it working fine simple scenario controller method returning pojo , spring converts json using "mappingjackson2httpmessageconverter" below:
{ "firstname": "john", "lastname": "smith", }
however properties name in json same name of getters in pojo. want modify name of properties in json dynamically.
actually requirement modify json property names based on logic. e.g if condition x properties name in json should below:
{ "fname": "john", "lname": "smith", }
if y properties name in json output should else like:
{ "mainname": "john", "secondname": "smith", }
so property name cannot tied pojo , cannot use @jsonproperty compile time want change @ runtime.
is there way override mappingjackson2httpmessageconverter , put logic decide json properties name there?
Comments
Post a Comment