title: How to filter properties on a self reference using Jackson?
body: <p>Let's say I have a class like this that I want to serialize with Jackson.</p>
  
  <pre><code>public class Product {
      int id;
      String name;
      List&lt;Product&gt; similarProducts;
  }
  </code></pre>
  
  <p>How do I end up with something like this?</p>
  
  <pre><code>{
      "id": 1,
      "name": "Product 1",
      "similarProducts": [
          {
              "id": 2,
              "name": "Product 2"
          },
          {
              "id": 3,
              "name": "Product 3"
          }
      ]
  }
  </code></pre>
  
  <p>I've see how to use @JsonProperty to do this by class or @JsonView to select things too but that also seems like it's by class (am I mistaken)? I'm not sure how to get this to work when I have a class that's referencing itself and the parent has many properties, while the child only has a few.</p>
  
  <p>Imagine this is an ecommerce site and you want to get the name and URL of similar products from a single JSON payload, but you don't need any other details of those similar products (children).</p>