title: Getting the response from a json response to Google Maps API in Java
body: <p>I need to develop a program where I have to calculate driving distance and time. Getting the request to the Google Maps API works, and I get a really big response. Now I want to extract the data I need from this response. The response is in json, and the program I make is made in Java. I have no idea to do this. I tried to just put the whole response in a string, and then search the data I need, like "distance" and extract a few characters that come after that. Problem with this is, if something changes in front of it, it's all going to be at different indexes in the huge string. </p>
  
  <p>A response is like this (only a bit of the big thing)</p>
  
  <pre><code>"copyrights" : "Kaartgegevens ©2017 GeoBasis-DE/BKG (©2009), Google",
       "legs" : [
          {
             "distance" : {
                "text" : "229 km",
                "value" : 229411
             },
             "duration" : {
                "text" : "2 uur 20 min.",
                "value" : 8417
             },
  </code></pre>
  
  <p>How do I easily extract the value of both "distance" and "duration"?</p>