title: How to globally remove attribute from Jackson JSON serialization?
body: <p>I have an object graph that contains objects that are (for purposes of this example) subclasses of type Foo.  The Foo class has an attribute on it called bar that I do not want to be serialized with my object graph.  So basically I want a way to say, whenever you serialize an object of type Foo, output everything but bar.</p>
  
  <pre><code>class Foo { // this is an external dependency
      public long getBar() { return null; } 
  }
  
  class Fuzz extends Foo {
      public long getBiz() { return null; }
  }
  
  public static void main(String[] args) {
      ObjectMapper mapper = new ObjectMapper();
      // I want to set a configuration on the mapper to
      // exclude bar from all things that are type Foo
  
      Fuzz fuzz = new Fuzz();
      System.out.println(mapper.writeValueAsString(fuzz));
      // writes {"bar": null, "biz": null} what I want is {"biz": null}
  }
  </code></pre>
  
  <p>Thanks,
  Ransom</p>
  
  <p>Edit: Used StaxMan suggestion, including code that I would end up using (and made bar a getter for example's sake)</p>
  
  <pre><code>interface Mixin {
      @JsonIgnore long getBar();
  }
  
  class Example {
      public static void main() {
          ObjectMapper mapper = new ObjectMapper();
          mapper.getSerializationConfig().addMixInAnnotations(Foo.class, Mixin.class);
          Fuzz fuzz = new Fuzz();
          System.out.println(mapper.writeValueAsString(fuzz));
          // writes {"biz": null} whoo!
      }
  } 
  </code></pre>