title: Parsing only a part from a large JSON
body: <p><img src="https://i.stack.imgur.com/o23eB.png" alt="enter image description here">I have a URL which contains contains a JSON array of some objects that I need for my android application.I've written the mapping class for these objects and also added</p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
  </code></pre>
  
  <p>for some fields that are unimportant for my end.My problem is that other than my precious data this URL also contains some extra and unnecessary information that I do not need to parse nor create a mapping class for in my part. I'm also using Jackson for quick parsing the JSON. So my question: how can I parse the whole URL but map only the desired JSON Array?</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  Map&lt;String,post[]&gt; map = mapper.readValue(new URL(urls.get(0)), Map.class);
  System.out.println(map.get("posts").length);
  </code></pre>
  
  <p>what I've written above compiles just fine but when I try to get the array of posts I get <code>java.lang.ClassCastException: java.util.ArrayList</code></p>
  
  <p>here's my code</p>
  
  <pre><code>        @Override
      protected String doInBackground(String... params) {
  
          try {
              Trial obj = mapper.readValue(new URL(urls.get(0)), Trial.class);
              System.out.println(obj.pois.size());
  
  
  
          } catch (JsonParseException e) {
              e.printStackTrace();
          } catch (JsonMappingException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
  
  
  
  
          return "done";
      }  
  </code></pre>
  
  <p><strong>Trial class</strong></p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
   public class Trial {
  
  public String status;
  public String count;
  public String pages;
  public ArrayList&lt;PointOfInterest&gt; pois;
  public String getStatus() {
      return status;
  }
  public void setStatus(String status) {
      this.status = status;
  }
  public String getCount() {
      return count;
  }
  public void setCount(String count) {
      this.count = count;
  }
  public String getPages() {
      return pages;
  }
  public void setPages(String pages) {
      this.pages = pages;
  }
  public ArrayList&lt;PointOfInterest&gt; getPois() {
      return pois;
  }
  public void setPois(ArrayList&lt;PointOfInterest&gt; pois) {
      this.pois = pois;
  }
  
  }
  </code></pre>
  
  <p><strong>Post Class</strong></p>
  
  <pre><code>@JsonIgnoreProperties(ignoreUnknown = true)
  public class Post{
  
  public String title;
  public String content;
  public String id;
  public String categoryIdFirstLevel;
  public String categoryIdSecondLevel;
  public String categoryIdThirdLevel;
  public String categoryIdFourthLevel;
  public String latitude;
  public String longitude;
  
  
  public Post(){
  
  }
  
  public Post(String title,String content,String id,String first,String second,String third,String fourth,String lat,String lon,ArrayList&lt;String&gt; urls){
  
      this.title=title;
      this.content=content;
      this.id=id;
      this.categoryIdFirstLevel=first;
      this.categoryIdSecondLevel=second;
      this.categoryIdThirdLevel=third;
      this.categoryIdFourthLevel=fourth;
      this.latitude=lat;
      this.longitude=lon;
  
  
  }
  
  public String getTitle() {
      return title;
  }
  
  public void setTitle(String title) {
      this.title = title;
  }
  
  public String getContent() {
      return content;
  }
  
  public void setContent(String content) {
      this.content = content;
  }
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  public String getCategoryIdFirstLevel() {
      return categoryIdFirstLevel;
  }
  
  public void setCategoryIdFirstLevel(String categoryIdFirstLevel) {
      this.categoryIdFirstLevel = categoryIdFirstLevel;
  }
  
  public String getCategoryIdSecondLevel() {
      return categoryIdSecondLevel;
  }
  
  public void setCategoryIdSecondLevel(String categoryIdSecondLevel) {
      this.categoryIdSecondLevel = categoryIdSecondLevel;
  }
  
  public String getCategoryIdThirdLevel() {
      return categoryIdThirdLevel;
  }
  
  public void setCategoryIdThirdLevel(String categoryIdThirdLevel) {
      this.categoryIdThirdLevel = categoryIdThirdLevel;
  }
  
  public String getCategoryIdFourthLevel() {
      return categoryIdFourthLevel;
  }
  
  public void setCategoryIdFourthLevel(String categoryIdFourthLevel) {
      this.categoryIdFourthLevel = categoryIdFourthLevel;
  }
  
  public String getLatitude() {
      return latitude;
  }
  
  public void setLatitude(String latitude) {
      this.latitude = latitude;
  }
  
  public String getLongitude() {
      return longitude;
  }
  
  public void setLongitude(String longitude) {
      this.longitude = longitude;
  }
  
  
  }
  </code></pre>