title: Parse nested json from url and extract values from array using java
body: <p>I have a json url link which i would like to read its json response and extract values into variables so that i can use them later</p>
  
  <pre><code>{
    "responseHeader": {
      "status": 0,
      "QTime": 4,
      "params": {
        "q": "*:*",
        "facet.field": "TESTARRAY",
        "indent": "true",
        "rows": "0",
        "wt": "json",
        "facet": "true"
      }
    },
    "response": {
      "numFound": 12,
      "start": 0,
      "docs": []
    },
    "facet_counts": {
      "facet_queries": {},
      "facet_fields": {
        "TESTARRAY": [
          "JON",
          22,
          "SMITH",
          34,
          "ROBERT",
          12
        ]
      },
      "facet_dates": {},
      "facet_ranges": {},
      "facet_intervals": {}
    }
  }
  </code></pre>
  
  <p>For extraction,I am using</p>
  
  <pre><code>JSONObject obj = new JSONObject(IOUtils.toString(new URL(jsonlink), Charset.forName("UTF-8")));
  JSONArray arr = obj.getJSONArray("TEST_ARRAY");
          Integer smithage=arr.get("SMITH");
  </code></pre>
  
  <p>So far this approach is not working.
  What would be the best way to deal with it
  Thanks in advance</p>