title: How to send an JSON array to another method
body: <p>I am fetching an JSON response from an API. 
  I should return those JSON response to another method with selected fields </p>
  
  <p>Here I am fetching all the JSON response and putting it to an JSONArray which I should return to another method.</p>
  
  <p>How to fetch both String and Long returning fields and put it into an JSON array and return it to another method</p>
  
  <pre><code>HttpClient client = HttpClientBuilder.create().build();
  HttpGet request = new HttpGet("/2.0/clusters/list");
  request.addHeader("Authorization", "bearerToken");
  request.addHeader("cache-control", "no-cache");
  
  
  HttpResponse response = client.execute(request);
  System.out.println("Response Code:" +
          response.getStatusLine().getStatusCode());
  String json = EntityUtils.toString(response.getEntity());
  
  System.out.println("Gather Details\n");
  
  JSONObject cluster = new JSONObject(json);
  JSONArray clusterJsonArray = cluster.getJSONArray("clusters");
  
  for (int i = 0; i &lt; clusterJsonArray.length(); i++) {
      JSONObject iteratingObj = array.getJSONObject(i);
      String id = iteratingObj.get("id").toString();
      String time = iteratingObj.get("time").toString();
  
      System.out.println("Id:" + id + "time:" + time + "\n");
  
      List&lt;String&gt; strList = new ArrayList&lt;&gt;();
  
      for (int p = 0; p &lt; clusterJsonArray.length(); p++) {
          strList.add(clusterJsonArray.getJSONObject(p).getString("id"));
          strList.add(clusterJsonArray.getJSONObject(p).getString("time"));
      }
  
      System.out.println("Arr:" + strList);
  
      if (response.getStatusLine().getStatusCode() != 200) {
          System.out.println("Failed HTTPresponse" + response.getStatusLine().getStatusCode() + "" + json);
      }
  }
  </code></pre>
  
  <p>Help me out to send the response with selected fields to other method in which that JSONarray should take both String and Long values and store it in one varible of JSONArray.</p>
  
  <p>Here is the incoming JSON:</p>
  
  <pre><code>"clusters": [ 
  { "id": "0411-0089ki", "driver": { }, "start_timestamp": 1568952332573, },
  </code></pre>
  
  <p>Here  <strong>JSONObject["time"] not a string</strong>  is the error i am facing when i am putting it to JSONArray</p>