title: Cannot parse JSONArray using GSON
body: <p>I have encountered a problem whilst developing my Android application.  My problem is that I don't know how to parse JSON code from an URL using GSON.  I searched Google and SO for about an hour or so, but nothing worked for me.  Everything I found on the internet referred to custom JSON code, not code from an URL.  Here is a small sample of the data I have.</p>
  
  <pre><code>  {
      "status": {
          "error": "NO",
          "code": 200,
          "description": "none",
          "message": "Request ok"
      },
      "geoLocation": {
          "city_id": "147",
          "city_long": "Saint-Laurent",
          "region_short": "QC",
          "region_long": "Quebec",
          "country_long": "Canada",
          "country_id": "43",
          "region_id": "35"
      },
      "stations": [
          {
              "country": "Canada",
              "price": "3.65",
              "address": "3885, Boulevard Saint-Rose",
              "diesel": "0",
              "id": "33862",
              "lat": "45.492367",
              "lng": "-73.710915",
              "station": "Shell",
              "region": "Quebec",
              "city": "Saint-Laurent",
              "date": "3 hours agp",
              "distance": "1.9km"
          },
          {
              "country": "Canada",
              "price": "3.67",
              "address": "3885, Saint-Mary",
              "diesel": "0",
              "id": "33872",
              "lat": "45.492907",
              "lng": "-73.740715",
              "station": "Shell",
              "region": "Quebec",
              "city": "Saint-Laurent",
              "date": "3 hours agp",
              "distance": "2.0km"
          }
      ]
  }
  </code></pre>
  
  <p>I am a beginner at JSON/GSON so I need a bit of help.  Here is what I have:</p>
  
  <pre><code>try {
              String sURL = "http://api.mygasfeed.com/stations/radius/(39.631439)/(-80.8005451)/(25)/reg/(price)/uc82wk25m0.json?callback=?";
              URL url = new URL(sURL);
              HttpURLConnection request = (HttpURLConnection) url.openConnection();
              request.connect();
  
              // Convert to a JSON object to print data
              JsonParser jp = new JsonParser(); //from gson
              JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent())); //convert the input stream to a json element
              JsonObject rootobj = root.getAsJsonObject(); //may be an array, may be an object.
              longitude = rootobj.get("price").getAsString();
              latitude = rootobj.get("address").getAsString();
          } catch (Exception e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>I tried a loop to parse the array but that failed miserably.  Any help regarding this problem is highly appreciated.</p>
  
  <p><strong>------------------------------EDIT-----------------------------------------------</strong>
  I am extremely sorry about the incorrrect JSON code.  I have updated the code but still cannot figure out the solution.</p>