json - make @jsonignore use a setter over a isMethod? -
this class
public class housejpaimpl implements house { public roomjpaimpl room; public roomjpaimpl getroom(){ return this.room; } public void setroom(roomjpaimpl room){ this.room = room; } @override public boolean isroom(){ return false; } } my code gets confused getroom , isroom.
caused by: java.lang.illegalargumentexception: conflicting getter definitions property "room": com.shared.model.restimpl.jpa.housejpaimpl#getroom(0 params) vs com.shared.model.restimpl.jpa.housejpaimpl#isroom(0 params)
i tried putting @jsonignore on isroom method dont room property in json.
is there way use getroom on isroom?
first of all, jackson 2.3 handle gracefully (see https://github.com/fasterxml/jackson-databind/issues/238).
but until gets released, there 2 main ways handle this:
- add
@jsonignoreonisroom(), keep@jsonpropertyongetroom() - change visibility settings filter out
isxxx()methods: can either set global settings (objectmapperhassetvisibility), or use annotation@jsonautodetecton classes
if isolated case, better off using first one.
Comments
Post a Comment