title: Mapping JSON data to Java objects
body: <p>I have been trying to map JSON data to Java objects, with the JSON file on my PC, but it always throws the exception:</p>
  
  <p><code>org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "title" (Class MovieResponse), not marked as ignorable
   at [Source: C:\M.json; line: 2, column: 13] (through reference chain: MovieResponse["title"])</code></p>
  
  <p>My data class:</p>
  
  <pre><code>import org.codehaus.jackson.annotate.JsonProperty;
  
  public class MovieResponse{
    private String title;
    private Integer year;
    @JsonProperty("mpaa_rating")
    private String mpaaRating;
    private Integer runtime;
    @JsonProperty("critics_consensus")
    private String criticsConsensus;
  
    public String getTitle(){
      return title;
    }
    public String setTitle(String t){
      return title = t;
    }
  
    public Integer getYear(){
      return year;
    }
    public Integer setYear(Integer y){
      return year = y;
    }
  
    public String getMpaa(){
      return mpaaRating;
    }
    public String setMpaa(String mp){
      return mpaaRating = mp;
    }
  
    public Integer getRuntime(){
      return runtime;
    }
    public Integer setRuntime(Integer r){
      return runtime = r;
    }
  
    public String getCritics(){
      return criticsConsensus;
    }
    public String setCritics(String c){
      return criticsConsensus = c;
    }
  
    @Override
    public String toString(){
      return "MovieResponse[title="+title+",year="+year+",mpaa_Rating="+mpaaRating+",runtime="+runtime+",critics_Consensus="+criticsConsensus
              +"]";
    }
  }
  </code></pre>
  
  <p>My mapper class:</p>
  
  <pre><code>import java.io.File;
  import java.io.IOException;
  import org.codehaus.jackson.JsonGenerationException;
  import org.codehaus.jackson.map.JsonMappingException;
  import org.codehaus.jackson.map.ObjectMapper;
  import java.net.*;
  import org.codehaus.jackson.annotate.JsonIgnoreProperties;
  @JsonIgnoreProperties
  public class Movie{
   public static void main(String[] args) throws MalformedURLException, URISyntaxException, IOException {
   MovieResponse a = new MovieResponse();
   ObjectMapper mapper = new ObjectMapper();
   try{
  
       MovieResponse response = new ObjectMapper().readValue(new File("C:\\M.json"), MovieResponse.class);
   }catch(MalformedURLException u){
      u.printStackTrace();
   }
   catch(IOException i){
      i.printStackTrace();
   }
   }
  </code></pre>
  
  <p>The json file contains following data:</p>
  
  <pre><code>{
    "title": "Toy Story 3",
    "year": 2010,
    "mpaa_rating": "G",
    "runtime": 103,
    "critics_consensus": "Deftly blending comedy, adventure, and honest emotion, Toy Story 3 is a rare second sequel that really works."
  }
  </code></pre>
  
  <p>What am I doing wrong? I am using the Jackson library.</p>