title: How to Serialise a JSON String to a JAVA Object using Jackson
body: <p>I am having trouble in deserialising the below JSON String to a Java Object.</p>
  <pre><code>{
      &quot;action&quot;: {
                 &quot;onWarning&quot;:{
                     &quot;alert&quot;:{
                            &quot;isEnabled&quot;: true,
                            &quot;name&quot;: &quot;&quot;
                             }
                     },
                 &quot;onError&quot;:{
                   &quot;alert&quot;:{
                          &quot;isEnabled&quot;: true,
                          &quot;name&quot;: &quot;&quot;
                          }
                     },
                  &quot;onSuccess&quot;:{
                   &quot;alert&quot;:{
                          &quot;isEnabled&quot;: true,
                          &quot;name&quot;: &quot;&quot;
                          }
                     }
               }
  }
  </code></pre>
  <p>The code below should work but i think my issue is with the mapper i am passing with it -</p>
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  JobConfig lib = mapper.readValue(jsonString, JobConfig.class);
  System.out.println(lib.action.onWarning.alert.isEnabled);
  </code></pre>
  <p>The mapper i pass with it is like below :</p>
  <p>Alert.java</p>
  <pre><code>public class Alert{
      @JsonProperty(&quot;isEnabled&quot;)
      public boolean isEnabled;
  
      @JsonProperty(&quot;name&quot;)
      public String name;
  }
  </code></pre>
  <p>AlertConfig.java</p>
  <pre><code>public class AlertConfig {
      
      @JsonProperty(&quot;onSuccess&quot;)
      public Alert onSuccess;
  
      @JsonProperty(&quot;onWarning&quot;)
      public Alert onWarning;
  
      @JsonProperty(&quot;onError&quot;)
      public Alert onError;
  }
  </code></pre>
  <p>JobConfig.java</p>
  <pre><code>public class JobConfig {
      @JsonProperty(&quot;action&quot;)
      public AlertConfig action;
  }
  </code></pre>
  <p>Error i get is :</p>
  <pre><code>com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field &quot;alert&quot; (class com.test.dv.service.domain.Alert), not marked as ignorable (2 known properties: &quot;name&quot;, &quot;isEnabled&quot;])
  </code></pre>
  <p>I am nor sure how to name the content of alert JSON as alert but it already has been named as Alert.</p>