Created
April 17, 2012 04:46
-
-
Save stickfigure/2403500 to your computer and use it in GitHub Desktop.
Jackson forgets @JSONVIEW when serializing through RefSerializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RefSerializer extends JsonSerializer<Ref> { | |
@Override | |
public void serialize(Ref value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { | |
jgen.writeObject(value.getValue()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/") | |
public class Run { | |
@GET | |
@Path("/thing") | |
@Produces(MediaType.APPLICATION_JSON) | |
@JsonView(ShouldShow.class) | |
public Ref<Thing> thing() { | |
return new Ref<Thing>(new Thing()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@JsonAutoDetect(fieldVisibility=Visibility.NONE, getterVisibility=Visibility.NONE, isGetterVisibility=Visibility.NONE) | |
public class Thing { | |
public class ShouldShow {} | |
public class ShouldNotShow extends ShouldShow {} | |
@JsonView(ShouldShow.class) | |
public String getBar() { | |
return "bar"; | |
} | |
@JsonView(ShouldNotShow.class) | |
public String getFoo() { | |
return "foo"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment