title: How to Parse JSON which contains the same key names
body: <p>I have the following JSON:</p>
  
  <pre><code> [
   {"hex":"3443d3", "squawk":"4673", "flight":"VLG3014 ","lat":37.716344, "lon":-2.913646, "validposition":1, "altitude":35000,"vert_rate":0,"track":225, "validtrack":1,"speed":427, "messages":74, "seen":0},
   {"hex":"345313", "squawk":"3767", "flight":"VLG2422 ", "lat":37.573568, "lon":-2.912750, "validposition":1, "altitude":38000,  "vert_rate":0,"track":72, "validtrack":1,"speed":420, "messages":1217, "seen":0}
   ]
  </code></pre>
  
  <p>The code is the following:</p>
  
  <pre><code>@Override
  protected String doInBackground(String... strings) {
  
      try {
          socket=new Socket("172.24.1.1",9000);
          System.out.println("CONECTED");
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      try {
          br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
          System.out.println("BufferedReader READY");
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      int i=0;
      while(i==0) {
          try {
              System.out.println("WAITING FOR MESSAGE");
              inputString=br.readLine();
          } catch (IOException e) {
              e.printStackTrace();
          }
          try {
              if(inputString!=null) {
                  jsonString = new JSONObject(inputString);
                  System.out.println(parseJSON(jsonString)[0]);
              }
          } catch (JSONException e) {
              //e.printStackTrace();
          }
  
      }
  
      return null;
  }
  
  private String[] parseJSON(JSONObject jsonObject) throws JSONException {
      String hex = jsonObject.getString("hex");
      String squawk = jsonObject.getString("squawk");
      String flight = jsonObject.getString("flight");
      String lat = jsonObject.getString("lat");
      String lon = jsonObject.getString("lon");
      String validposition = jsonObject.getString("validposition");
      String altitude = jsonObject.getString("altitude");
      String vert_rate = jsonObject.getString("vert_rate");
      String track= jsonObject.getString("track");
      String validtrack = jsonObject.getString("validtrack");
      String speed = jsonObject.getString("speed");
      String messages = jsonObject.getString("messages");
      String seen = jsonObject.getString("seen");
  
      String[] answer={hex,squawk,flight,lat,lon,validposition,altitude,vert_rate,track,validtrack,speed,messages,seen};
      return answer;
  }
  </code></pre>
  
  <p>I receive the entire JSON in my app. When I get "hex", I obtain 345313 code. I want to have a vector of "hex" with both values, my question is:
  How can I obtain both values without using for loop? Is there any JSON method to obtain both at the same time and save them in an array?</p>