title: Jackson equivalent to @XmlSeeAlso
body: <p>I am writing a RESTful web service using Java and Jersey, where the service will accept either XML or JSON inputs. Jackson is used as the JSON deserializer, and integrated into the Jersey config.</p>
  
  <p>One of the endpoints is a POST request to a URL, where the content can be one of several different Java classes, and there is a common base class. These classes - with XML annotations - are:</p>
  
  <pre><code>@XmlRootElement(name = "action")
  @XmlAccessorType(XmlAccessType.NONE)
  @XmlSeeAlso({ FirstAction.class, SecondAction.class, ThirdAction.class })
  public abstract class BaseAction {
  }
  
  @XmlRootElement(name = "first-action")
  @XmlAccessorType(XmlAccessType.NONE)
  public class FirstAction extends BaseAction implements Serializable {
  }
  
  // Likewise for SecondAction, ThirdAction
  </code></pre>
  
  <p>In my resource I can declare a method like:</p>
  
  <pre><code>@POST
  @Path("/{id}/action")
  public Response invokeAction(@PathParam("id") String id, BaseAction action) {...}
  </code></pre>
  
  <p>Then I can POST an XML fragment that looks like <code>&lt;firstAction/&gt;</code> and my method will be invoked with a <code>FirstAction</code> instance. So far so good.</p>
  
  <p>Where I'm struggling is getting the JSON deserialization to work as seamlessly as the XML deserialization. Where the <code>@XmlSeeAlso</code> annotation was critical to get the XML deserialization working properly, it seemed that the equivalent for JSON was <code>@JsonSubTypes</code>. So I annotated the classes like this:</p>
  
  <pre><code>// XML annotations removed for brevity, but they are present as in the previous code snippet
  @JsonSubTypes({ @JsonSubTypes.Type(name = "first-action", value = FirstAction.class),
      @JsonSubTypes.Type(name = "second-action", value = SecondAction.class),
      @JsonSubTypes.Type(name = "third-action", value = ThirdAction.class) })
  public abstract class BaseAction {
  }
  
  @JsonRootName("first-action")
  public class FirstAction extends BaseAction implements Serializable {
  }
  
  // Likewise for SecondAction, ThirdAction
  </code></pre>
  
  <p>I then feed it my test input: <code>{ "first-action": null }</code> but all I can get is:</p>
  
  <p>"org.codehaus.jackson.map.JsonMappingException: Root name 'first-action' does not match expected ('action') for type [simple type, class com.alu.openstack.domain.compute.server.actions.BaseAction]"</p>
  
  <p>Unfortunately since I'm trying to be compatible with someone else's API I can't change my sample input - <code>{ "first-action": null }</code> has to work, and deliver to my method an object of class FirstAction. (The action doesn't have any fields, which is why null shouldn't be a problem - it's the type of the class that's important).</p>
  
  <p>What's the correct way to have the JSON deserialization work in the same way as the XML deserialization already is?</p>