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 @jsonignore on isroom(), keep @jsonproperty on getroom()
  • change visibility settings filter out isxxx() methods: can either set global settings (objectmapper has setvisibility), or use annotation @jsonautodetect on classes

if isolated case, better off using first one.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -