How to map a nested value to a property using Jackson annotations?
<p>Let's say I'm making a call to an API that responds with the following JSON for a product:</p>

<pre><code>{
  "id": 123,
  "name": "The Best Product",
  "brand": {
     "id": 234,
     "name": "ACME Products"
  }
}
</code></pre>

<p>I'm able to map the product id and name just fine using Jackson annotations:</p>

<pre><code>public class ProductTest {
    private int productId;
    private String productName, brandName;

    @JsonProperty("id")
    public int getProductId() {
        return productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    @JsonProperty("name")
    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }
}
</code></pre>

<p>And then using the fromJson method to create the product:</p>

<pre><code>  JsonNode apiResponse = api.getResponse();
  Product product = Json.fromJson(apiResponse, Product.class);
</code></pre>

<p>But now I'm trying to figure out how to grab the brand name, which is a nested property. I was hoping that something like this would work:</p>

<pre><code>    @JsonProperty("brand.name")
    public String getBrandName() {
        return brandName;
    }
</code></pre>

<p>But of course it didn't. Is there an easy way to accomplish what I want using annotations? </p>

<blockquote>
  <p>The actual JSON response I'm trying to parse is very complex, and I don't want to have to create an entire new class for every sub-node, even though I only need a single field.</p>
</blockquote>