Is the a mechanism in Spring MVC to rename bean for JSON -


is there way rename bean properties in spring mvc response, i'm using content negotiation , response returned json.

for example, if have class field called 'title'

public class entity {      @xmlattribute     private string title; } 

in json created displayed so:

"entity":{     "mycompany:title": "this title" } 

@xmlattribute annotation has name attribute, suggest try it:-

public class entity {      @xmlattribute(name = "mycompany:title")     private string title; } 


updated: answer looks wrong. try following:

@xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class entity {      @xmlelement(name = "mycompany:title")     private string title; } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -