title: How to use @JsonTypeInfo, @JsonSubType to determine a field type based on a sibling field's value?
body: <p>Say I have a class structure like this :-</p>
  <pre><code>class ShapeRequest {
  
      ShapeInfo shapeInfo;
      Shape shape;
  
      static class ShapeInfo {
          String shapeName;
          String shapeDimension;
      }
  
      static abstract class Shape {
  
      }
  
      static class Square extends Shape{
          int area;
      }
  
      static class Circle extends Shape{
          int area;
      }
  }
  </code></pre>
  <p>How can I deserialize the ShapeRequest in a way that field <strong>shape</strong>, is mapped to Square or Circle type, depending on the <strong>shapeInfo.shapeName</strong> field value?</p>
  <p>For example, the following JSON should map to ShapeRequest with Circle shape type, because shapeInfo.shapeName = &quot;circle&quot;</p>
  <pre><code>{
    &quot;shapeInfo&quot;: {
      &quot;shapeName&quot;: &quot;circle&quot;,
      &quot;shapeDimension&quot;: &quot;2&quot;
    },
    &quot;shape&quot;: {
      &quot;area&quot;: 10
    }
  }
  </code></pre>