title: Jaxb annotations to deserialize json data using Jackons
body: <p>I do have a simple json data and my pojo is annotated with jaxb annotations. I wanted to deserialize it WITHOUT using json annotations. </p>
  
  <p>(It's must, please do NOT suggest to use both annotations on pojo). </p>
  
  <p>Jackson confirms (that's what I understood) that it's possible through
  <a href="http://wiki.fasterxml.com/JacksonJAXBAnnotations" rel="nofollow">http://wiki.fasterxml.com/JacksonJAXBAnnotations</a>
  <a href="https://github.com/FasterXML/jackson-module-jaxb-annotations" rel="nofollow">https://github.com/FasterXML/jackson-module-jaxb-annotations</a></p>
  
  <p>But when I ran the code, it does NOT provide the desired result. </p>
  
  <p>Here is the pojo.</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "Simple_root")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Simple {
      @XmlElement(name = "x")
      private String firstName;
      @XmlElement(name = "y")
      private String lastName;
  
      public String getFirstName() {
          return firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  }
  </code></pre>
  
  <p>Below is the test class with two test methods using jackson ObjectMapper.</p>
  
  <pre><code>import org.junit.Assert;
  import org.junit.Test;
  
  import com.fasterxml.jackson.databind.AnnotationIntrospector;
  import com.fasterxml.jackson.databind.DeserializationFeature;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
  import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
  
  public class XmlMapperTest {
  
      @Test
      public void jsonDeserialize_using_JaxbAnnotationIntrospector() throws Exception {
          ObjectMapper jsonMapper = new ObjectMapper();
          jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  
          AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
          jsonMapper.getDeserializationConfig().with(introspector);
          jsonMapper.getSerializationConfig().with(introspector);
  
          Simple simple = jsonMapper.readValue("{\"Simple_root\": {\"x\": \"2\", \"y\": \"4\"}}", Simple.class);
          Assert.assertNotNull(simple.getFirstName());
          Assert.assertNotNull(simple.getLastName());
      }
  
      @Test
      public void jsonDeserialize_using_JaxbAnnotationModule() throws Exception {
          ObjectMapper jsonMapper = new ObjectMapper();
          jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  
          JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule();
          jsonMapper.registerModule(jaxbModule);
  
          Simple simple = jsonMapper.readValue("{\"Simple_root\": {\"x\": \"2\", \"y\": \"4\"}}", Simple.class);
          Assert.assertNotNull(simple.getFirstName());
          Assert.assertNotNull(simple.getLastName());
      }
  }
  </code></pre>
  
  <p>Any help would be appreciated, as I know I am definitely missing something which I couldn't find out in a day and 2 hours before bedtime.</p>