title: Java JSON RESTful web services - Filtering fields
body: <p><strong>Scenario</strong></p>
  
  <ul>
  <li>Jersey/JacksonJson for my RESTful web services requests.  </li>
  <li>An entity A that has properties X,Y,Z. </li>
  <li>2 RESTful requests.  </li>
  <li>Request 1 should return entity A with properties X,Y in the JSON response</li>
  <li>Request 2 should return entity A with properties X,Y,Z in the JSON response</li>
  <li>Entity A is configured such that property Z is using @JsonIgnore so it is not returned in the JSON response</li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <p>How do I return property Z in Request 2 if it is set to @JsonIgnore in the entity?  Is there are better way to do this dynamically besides using @JsonIgnore?
  Below is some "Demonstration" code to help clarify my question.</p>
  
  <pre><code>@Entity
  Class A implements Serializable {
    String X;
    String Y;
    String Z;
  
    @JsonIgnore
    public String getZ() {
      return Z;
    }
  }
  
  @Path("form")
  Class Request {
      @GET
      @Path("request1")
      @Produces({"application/json"})
      public A request1() {
        return A;
      }
  
      @GET
      @Path("request2")
      @Produces({"application/json"})
      public A request2() {
        return A;
      }
  }
  </code></pre>