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

Popular posts from this blog

html - height not adding height to a empty div -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

python - Robot Framework location and name of keyword -