title: Using conditions to dynamically exclude POJO property in Jackson json serialization
body: <p>I have a requirement to dynamically exclude certain property within a List of a defined POJO.
  The main POJO to be serialized is:</p>
  
  <pre><code>public class Foo
  {
      List&lt;Bar&gt; bar;
  
      public void setBar(List&lt;Bar&gt; bar)
      {
          this.bar = bar;
      }
  
      public List&lt;Bar&gt; getBar()
      {
          return this.bar;
      }
  
      public static class Bar
      {
          private int id;
          private boolean ignoreId;
          private String name;
  
          public void setId(int id)
          {
              this.id = id;
          }
  
          public int getId()
          {
              return this.id;
          }
  
          public void setIgnoreId(boolean ignoreId)
          {
              this.ignoreId = ignoreId;
          }
  
          public boolean isIgnoreId()
          {
              return this.ignoreId;
          }
  
          public void setName(String name)
          {
              this.name = name;
          }
  
          public String getName()
          {
              return this.name;
          }
      }
  }
  </code></pre>
  
  <p>id is to be ignored if ignoreId = true, like so:</p>
  
  <pre><code>[
      { "id": "1", "name": "one" },
      { "name": "two" }
      { "name": "three" }
      { "id": "4", "name": "four" }
  ]
  </code></pre>
  
  <p>At the moment, I have tried using <code>JsonFilter</code> and <code>JacksonJsonViews</code> but couldn't get the required output.
  I would be glad if any pointer can be given towards achieving this.</p>