title: How To Extract Data From JSON with Rest Template in Java
body: <p>i have to extract the first 5 articles from <a href="https://newsapi.org/v2/top-headlines?sources=bbc-news&amp;apiKey=19acc3a371d145ecb37a093f9985ea21" rel="nofollow noreferrer">https://newsapi.org/v2/top-headlines?sources=bbc-news&amp;apiKey=19acc3a371d145ecb37a093f9985ea21</a>, having a result like this: </p>
  
  <pre><code>{
      "total": 5,
      "articles": [
  {
      "source": "Ilmessaggero.it",
      "title": "Title",
      "author": "Author",
      "url": "URL"
    }
   ]
  }
  </code></pre>
  
  <p>I did this, having all the JSON as String as output for the localhost...</p>
  
  <pre><code>@RequestMapping("/news")
      public Article connection() {
  
          return restTemplate.getForObject
                  ("https://newsapi.org/v2/top-headlines?sources=bbc-news&amp;apiKey=19acc3a371d145ecb37a093f9985ea21",  Article.class);
  </code></pre>
  
  <p>The result in the localhost is: </p>
  
  <pre><code>{"source":null,"title":null,"author":null,"url":null}
  </code></pre>
  
  <p>But the problem now is, how do i put the data into the list of articles?
  and how do i save them into mongodb? thanks for the effort</p>